[Python-checkins] cpython (2.7): Issue #13373: multiprocessing.Queue.get() could sometimes block indefinitely

antoine.pitrou python-checkins at python.org
Thu Nov 10 00:45:22 CET 2011


http://hg.python.org/cpython/rev/e7b6dca28a2f
changeset:   73471:e7b6dca28a2f
branch:      2.7
parent:      73450:554802e562fa
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Thu Nov 10 00:33:50 2011 +0100
summary:
  Issue #13373: multiprocessing.Queue.get() could sometimes block indefinitely
when called with a timeout.  Patch by Arnaud Ysmal.

files:
  Lib/multiprocessing/queues.py |  6 +++++-
  Misc/ACKS                     |  1 +
  Misc/NEWS                     |  3 +++
  3 files changed, 9 insertions(+), 1 deletions(-)


diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py
--- a/Lib/multiprocessing/queues.py
+++ b/Lib/multiprocessing/queues.py
@@ -126,7 +126,11 @@
             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
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -924,6 +924,7 @@
 Danny Yoo
 George Yoshida
 Masazumi Yoshikawa
+Arnaud Ysmal
 Bernard Yue
 Moshe Zadka
 Milan Zamazal
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -76,6 +76,9 @@
 Library
 -------
 
+- Issue #13373: multiprocessing.Queue.get() could sometimes block indefinitely
+  when called with a timeout.  Patch by Arnaud Ysmal.
+
 - Issue #3067: Enhance the documentation and docstring of
   locale.setlocale().
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list