Make `asyncio.Lock.locked()` return `True` when there are waiters
Open
Nobody has claimed this yet.
stdlib
topic-asyncio
triaged
type-feature
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
In issue https://github.com/python/cpython/issues/97028 everyone seemed to agree that asyncio.{Lock,Semaphore}.locked() should return True if there are waiters, but this change was implemented only for Semaphore.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-153989
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading asyncio.Lock.locked() alongside asyncio.Semaphore.locked(), then review issue 97028 for the agreed semantics. Check linked PR gh-153989 before starting, since it may already contain the work; done means Lock.locked() returns True when the lock has waiters, with matching tests and behavior for existing lock states.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100