Skip to content

Conversation

@colesbury
Copy link
Contributor

@colesburycolesbury commented Nov 9, 2023

The @critical_section directive instructs Argument Clinic to generate calls to Py_BEGIN_CRITICAL_SECTION() and Py_END_CRITICAL_SECTION() around the bound function. In --disable-gil builds, these calls will lock and unlock the self object. They are no-ops in the default build.

This is used in one place (_io._Buffered.close) as a demonstration. Subsequent PRs will use it more widely in the _io.Buffered bindings.

The `@critical_section` directive instructs Argument Clinic to generate calls to `Py_BEGIN_CRITICAL_SECTION()` and `Py_END_CRITICAL_SECTION()` around the bound function. In `--disable-gil` builds, these calls will lock and unlock the `self` object. They are no-ops in the default build. This is used in one place (`_io._Buffered.close`) as a demonstration. Subsequent PRs will use it more widely in the `_io.Buffered` bindings.
@colesburycolesbury marked this pull request as ready for review November 9, 2023 18:56
@erlend-aasland
Copy link
Contributor

Thanks! Can you please add tests? Also, we need to update the docs over at the devguide. Can you prepare a PR for that?

@colesbury
Copy link
ContributorAuthor

I added two tests to clinic.test.c and put up a PR for the devguide (python/devguide#1217)

@erlend-aasland
Copy link
Contributor

@AlexWaygood, are you fine with the clinic.py changes?

Copy link
Member

@AlexWaygoodAlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, sorry for the slow response! I'm not sure I fully understand what the @critical_sectiondoes, but that's more of a documentation question -- this PR looks fine. I'll try to find some time today or tomorrow to comment on the devguide PR you've put up :)

@AlexWaygoodAlexWaygood merged commit 324531d into python:mainNov 14, 2023
@colesburycolesbury deleted the critical_sections-ac branch November 14, 2023 16:05
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
python#111904) The `@critical_section` directive instructs Argument Clinic to generate calls to `Py_BEGIN_CRITICAL_SECTION()` and `Py_END_CRITICAL_SECTION()` around the bound function. In `--disable-gil` builds, these calls will lock and unlock the `self` object. They are no-ops in the default build. This is used in one place (`_io._Buffered.close`) as a demonstration. Subsequent PRs will use it more widely in the `_io.Buffered` bindings.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
python#111904) The `@critical_section` directive instructs Argument Clinic to generate calls to `Py_BEGIN_CRITICAL_SECTION()` and `Py_END_CRITICAL_SECTION()` around the bound function. In `--disable-gil` builds, these calls will lock and unlock the `self` object. They are no-ops in the default build. This is used in one place (`_io._Buffered.close`) as a demonstration. Subsequent PRs will use it more widely in the `_io.Buffered` bindings.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@colesbury@erlend-aasland@AlexWaygood