Repository navigation
#gh-138121 Make asyncio.Lock.locked return True when waiters exist - #153989
EmBeckwith wants to merge 2202 commits into
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
The following commit authors need to sign the Contributor License Agreement: |
|
This PR is stale because it has been open for 90 days with no activity. |
OsmnvAslan
left a comment
There was a problem hiding this comment.
Thanks for picking this up! I checked it against current main (it merges cleanly, and test_locks passes). Two things from a small script:
locked()no longer returns a bool: it'sNonefor a lock that was never contended, and an emptydequeafter contention. Wrapping it inbool(...)would keep the return type.- If the only waiter is cancelled but still in
_waiters,locked()returns True whileacquire()takes the lock immediately. Checkingany(not w.cancelled() for w in (self._waiters or ())), asSemaphore.locked()does, would keep the two consistent (and also returns a bool).
A test with the scenario from the issue would also help.
|
Cool. I'll get those changes added in! |
3a55835 to
3f2b2bb
Compare
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
1 similar comment
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
…python#161725) Previously, xxlimited extension modules were only built in the Release configuration.
…r low memory (python#154019) Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
…d with urllib.request.ProxyHandler (python#161729) pythongh-52330 Document how a proxy auto-config (PAC) file can be used with urllib.request.ProxyHandler We will point to the pypi package pypac which supports PAC discovery and can be extended as a custom ProxyHandler to be used with urllib.request. The documentation will point to the pypi package and share high-level example of using this.
…honGH-155070) * Don't try to close mmap in SharedMemory.__del__ * Add a test for SharedMemory finalization with a live buffer, expand NEWS --------- Co-authored-by: Gregory P. Smith <greg@krypto.org>
) * pythongh-154643: Only use _Py_STDC_VERSION when defined This fixes: $ g++ -I/usr/include/python3.15 -c -Werror=undef test.cpp In file included from /usr/include/python3.15/Python.h:68, from test.cpp:1: /usr/include/python3.15/pyport.h:494:9: error: ‘_Py_STDC_VERSION’ is not defined, evaluates to ‘0’ [-Werror=undef] 494 | # elif _Py_STDC_VERSION >= 201112L && !defined(__STDC_NO_THREADS__) | ^~~~~~~~~~~~~~~~ cc1plus: some warnings being treated as errors For any test.cpp that has #include <Python.h>. For locating the place for the added test, I used LLM. The main issue I could reproduce was in Include/pyport.h. Include/cpython/pyatomic.h was updated for completeness. Include/internal/mimalloc/mimalloc/atomic.h also has this for __STDC_VERSION__ but was left untouched as it is code from a bundled project and is likely not exposed publicly. Assisted-By: Claude Opus 4.6 * Also add test for C * Add -Werror=undef to PUBLIC_CFLAGS & PEDANTIC_CXXFLAGS in setup.py * Drop tests, we use PUBLIC_CFLAGS & PEDANTIC_CXXFLAGS instead
gh-138121 Fix Asyncio.Lock.locked returning True when waiters exist
Currently the behaviour described by
Asyncio.Lock.locked()is returning True when there are pending waiters in the loop. As described by the issue, this behaviour is different to theSemaphoreprimitive.