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

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


http://hg.python.org/cpython/rev/f34b4e250b44
changeset:   73473:f34b4e250b44
parent:      73470:bdb3f0e7e268
parent:      73472:9328080a19c0
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Thu Nov 10 00:38:25 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
@@ -129,7 +129,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
@@ -1068,6 +1068,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
@@ -365,6 +365,9 @@
 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.
 

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


More information about the Python-checkins mailing list