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 bb4c7d8..cf51307 100644
--- 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
index f204ecb..d81f75c 100644
--- 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
index e7655f3..b46c585 100644
--- 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.