This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author altuezi
Recipients altuezi
Date 2016-12-15.20:44:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1481834665.78.0.584713250682.issue28982@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2016-12-15 20:44:25altuezisetrecipients: + altuezi
2016-12-15 20:44:25altuezisetmessageid: <1481834665.78.0.584713250682.issue28982@psf.upfronthosting.co.za>
2016-12-15 20:44:25altuezilinkissue28982 messages
2016-12-15 20:44:25altuezicreate