From b38897fc91c7f4b80bc2025ade219674d7b78bf3 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola' Date: Wed, 17 Apr 2013 13:08:59 +0200 Subject: Fix issue #17707: multiprocessing.Queue's get() method does not block for short timeouts. --- Lib/multiprocessing/connection.py | 2 +- Lib/test/test_multiprocessing.py | 7 +++++++ Misc/NEWS | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index 1d65f46..df57906 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -865,7 +865,7 @@ else: if hasattr(select, 'poll'): def _poll(fds, timeout): if timeout is not None: - timeout = int(timeout) * 1000 # timeout is in milliseconds + timeout = int(timeout * 1000) # timeout is in milliseconds fd_map = {} pollster = select.poll() for fd in fds: diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 3fb07f6..14ec61c 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -698,6 +698,13 @@ class _TestQueue(BaseTestCase): for p in workers: p.join() + def test_timeout(self): + q = multiprocessing.Queue() + start = time.time() + self.assertRaises(pyqueue.Empty, q.get, True, 0.2) + delta = time.time() - start + self.assertGreaterEqual(delta, 0.19) + # # # diff --git a/Misc/NEWS b/Misc/NEWS index 0b118d5..be59be0 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -29,6 +29,9 @@ Core and Builtins Library ------- +- Issue #17707: multiprocessing.Queue's get() method does not block for short + timeouts. + - Issue #17012: shutil.which() no longer fallbacks to the PATH environment variable if empty path argument is specified. Patch by Serhiy Storchaka. -- cgit v0.12