Skip to content

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
@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