Pure Python `SimpleQueue.get()` raises `ValueError` when block is false and timeout is given
Open
Nobody has claimed this yet.
stdlib
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
The docs for SimpleQueue.get() say that timeout is ignored when block is false. The C version does that, but the pure Python version passes timeout to threading.Semaphore.acquire() and fails:
>>> from queue import _PySimpleQueue
>>> _PySimpleQueue().get(block=False, timeout=1)
Traceback (most recent call last):
...
ValueError: can't specify timeout for non-blocking acquire
The C version raises Empty here.
A PR is on the way.
Linked PRs
- gh-156477
- gh-156487
- gh-156488
- gh-156489
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 with the pure Python _PySimpleQueue.get() implementation and compare its handling of block=False and timeout with the C version and the SimpleQueue documentation. Done means a non-blocking get with a supplied timeout follows the documented behavior and raises Empty rather than ValueError; check the existing behavior shown in the issue.
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
- Clearly specified
- Newbie friendliness
- 25/100