From: Antoine Pitrou Date: Wed, 9 Nov 2011 23:37:09 +0000 (+0100) Subject: Issue #13373: multiprocessing.Queue.get() could sometimes block indefinitely X-Git-Tag: v3.2.3rc1~405 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a3651136790d3ec8291a07b1a5af8f0353e59c20;p=thirdparty%2FPython%2Fcpython.git Issue #13373: multiprocessing.Queue.get() could sometimes block indefinitely when called with a timeout. Patch by Arnaud Ysmal. --- diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py index 3280a2533d7d..51d991245c1a 100644 --- a/Lib/multiprocessing/queues.py +++ b/Lib/multiprocessing/queues.py @@ -126,7 +126,11 @@ class Queue(object): if not self._rlock.acquire(block, timeout): raise Empty try: - if not self._poll(block and (deadline-time.time()) or 0.0): + if block: + timeout = deadline - time.time() + if timeout < 0 or not self._poll(timeout): + raise Empty + elif not self._poll(): raise Empty res = self._recv() self._sem.release() diff --git a/Misc/ACKS b/Misc/ACKS index 6f2c2a11e443..2fe91749e006 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1001,6 +1001,7 @@ Bob Yodlowski Danny Yoo George Yoshida Masazumi Yoshikawa +Arnaud Ysmal Bernard Yue Moshe Zadka Milan Zamazal diff --git a/Misc/NEWS b/Misc/NEWS index 19e796068892..24840b172e10 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -73,6 +73,9 @@ Core and Builtins Library ------- +- Issue #13373: multiprocessing.Queue.get() could sometimes block indefinitely + when called with a timeout. Patch by Arnaud Ysmal. + - Issue #13254: Fix Maildir initialization so that maildir contents are read correctly.