New submission from Ryan Brindley:
Hey dev team,
According to the following test, `q.get(True, 0)` always raises queue.Empty.
from multiprocessing import Queue
q = Queue()
q.put('foo')
q.get(True, 0) # raises Empty
This result throws me off as I was expecting a similar result to the underlying
poll/select timeout where 0 actually just means non-blocking.
After reviewing Lib/multiprocessing/queues.py, I found the condition where the
timeout, after the adjustment for the time required to acquire the lock, would
not even call poll() if it was less than 0.
So, linked is a simple PR that I'm offering as a suggested fix/behavior-change
of Queue.get's handling of timeout=0 to match the underlying poll/select
handling (aka non-blocking).
Cheers,
Ryan Brindley
----------
components: Library (Lib)
messages: 283344
nosy: Ryan Brindley
priority: normal
pull_requests: 5
severity: normal
status: open
title: multiprocessing.Queue.get(block=True, timeout=0) always raises
queue.Empty
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28982>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com