Repository navigation
#gh-138121 Make asyncio.Lock.locked return True when waiters exist - #153989
EmBeckwith wants to merge 4 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 |
|
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 |
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.