Skip to content

gh-111903: Add @critical_section directive to Argument Clinic. #111904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 14, 2023

Conversation

colesbury
Copy link
Contributor

@colesbury colesbury 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.
@colesbury colesbury 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
Contributor Author

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

@AlexWaygood AlexWaygood 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_section does, 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 :)

@AlexWaygood AlexWaygood merged commit 324531d into python:main Nov 14, 2023
@colesbury colesbury 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 free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants