Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a365113

Browse files
committed
Issue #13373: multiprocessing.Queue.get() could sometimes block indefinitely
when called with a timeout. Patch by Arnaud Ysmal.
1 parent 69d44fd commit a365113

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

Lib/multiprocessing/queues.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ def get(self, block=True, timeout=None):
126126
if not self._rlock.acquire(block, timeout):
127127
raise Empty
128128
try:
129-
if not self._poll(block and (deadline-time.time()) or 0.0):
129+
if block:
130+
timeout = deadline - time.time()
131+
if timeout < 0 or not self._poll(timeout):
132+
raise Empty
133+
elif not self._poll():
130134
raise Empty
131135
res = self._recv()
132136
self._sem.release()

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ Bob Yodlowski
10011001
Danny Yoo
10021002
George Yoshida
10031003
Masazumi Yoshikawa
1004+
Arnaud Ysmal
10041005
Bernard Yue
10051006
Moshe Zadka
10061007
Milan Zamazal

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ Core and Builtins
7373
Library
7474
-------
7575

76+
- Issue #13373: multiprocessing.Queue.get() could sometimes block indefinitely
77+
when called with a timeout. Patch by Arnaud Ysmal.
78+
7679
- Issue #13254: Fix Maildir initialization so that maildir contents
7780
are read correctly.
7881

0 commit comments

Comments
 (0)