From 6a570d6b9af07a03859dd2175086e45ab60f4ee9 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Thu, 10 Nov 2011 00:33:50 +0100 Subject: [PATCH] Issue #13373: multiprocessing.Queue.get() could sometimes block indefinitely when called with a timeout. Patch by Arnaud Ysmal. --- Lib/multiprocessing/queues.py | 6 +++++- Misc/ACKS | 1 + Misc/NEWS | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py index b7eecefa20..433c7e29de 100644 --- a/Lib/multiprocessing/queues.py +++ b/Lib/multiprocessing/queues.py @@ -126,7 +126,11 @@ class Queue(object): 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 97c961cb12..e6d9865bff 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -924,6 +924,7 @@ Bob Yodlowski Danny Yoo George Yoshida Masazumi Yoshikawa +Arnaud Ysmal Bernard Yue Moshe Zadka Milan Zamazal diff --git a/Misc/NEWS b/Misc/NEWS index 21fdbdce81..9517677ee2 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -76,6 +76,9 @@ Core and Builtins 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(). -- 2.40.0