Skip to content
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

gh-117435: Make SemLock thread-safe in free-threaded build #117436

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

colesbury
Copy link
Contributor

@colesbury colesbury commented Apr 1, 2024

Use critical sections to make acquire(), release(), and _count() thread-safe without the GIL.

Use critical sections to make acquire, release, and _count thread-safe
without the GIL.
@colesbury
Copy link
Contributor Author

colesbury commented Apr 1, 2024

It feels a bit silly to put a lock in the lock implementation, but it's surprisingly difficult to make the modifications to count thread-safe, particularly for the kind == SEMAPHORE use-case where multiple threads may "release" a semaphore concurrently.

@colesbury colesbury merged commit de5ca0b into python:main Apr 4, 2024
38 checks passed
@colesbury colesbury deleted the gh-117435-semlock branch April 4, 2024 18:09
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
…ython#117436)

Use critical sections to make acquire, release, and _count thread-safe
without the GIL.
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.

2 participants