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

Skip to content

Commit 0215724

Browse files
committed
Issue #13373: multiprocessing.Queue.get() could sometimes block indefinitely
when called with a timeout. Patch by Arnaud Ysmal.
2 parents 6139c1b + a365113 commit 0215724

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
@@ -129,7 +129,11 @@ def get(self, block=True, timeout=None):
129129
if not self._rlock.acquire(block, timeout):
130130
raise Empty
131131
try:
132-
if not self._poll(block and (deadline-time.time()) or 0.0):
132+
if block:
133+
timeout = deadline - time.time()
134+
if timeout < 0 or not self._poll(timeout):
135+
raise Empty
136+
elif not self._poll():
133137
raise Empty
134138
res = self._recv()
135139
self._sem.release()

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,7 @@ Bob Yodlowski
10681068
Danny Yoo
10691069
George Yoshida
10701070
Masazumi Yoshikawa
1071+
Arnaud Ysmal
10711072
Bernard Yue
10721073
Moshe Zadka
10731074
Milan Zamazal

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ Core and Builtins
365365
Library
366366
-------
367367

368+
- Issue #13373: multiprocessing.Queue.get() could sometimes block indefinitely
369+
when called with a timeout. Patch by Arnaud Ysmal.
370+
368371
- Issue #13254: Fix Maildir initialization so that maildir contents
369372
are read correctly.
370373

0 commit comments

Comments
 (0)