Skip to content

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

Merged
colesbury merged 1 commit into
python:mainfrom
colesbury:gh-117435-semlock
Apr 4, 2024
Merged

colesbury merged 1 commit into
python:mainfrom
colesbury:gh-117435-semlock

Conversation

@colesbury

@colesbury colesbury commented Apr 1, 2024 •

Copy link
Copy Markdown
Contributor

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

colesbury commented Apr 1, 2024 •

Copy link
Copy Markdown
Contributor Author

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

2 participants