Skip to content

Commit 3083071

Browse files
committed
Fix issue python#17707: multiprocessing.Queue's get() method does not block for short timeouts.
1 parent 22b9e65 commit 3083071

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Lib/multiprocessing/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ def wait(object_list, timeout=None):
862862
if hasattr(select, 'poll'):
863863
def _poll(fds, timeout):
864864
if timeout is not None:
865-
timeout = int(timeout) * 1000 # timeout is in milliseconds
865+
timeout = int(timeout * 1000) # timeout is in milliseconds
866866
fd_map = {}
867867
pollster = select.poll()
868868
for fd in fds:

Lib/test/test_multiprocessing.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,13 @@ def test_task_done(self):
699699
for p in workers:
700700
p.join()
701701

702+
def test_timeout(self):
703+
q = multiprocessing.Queue()
704+
start = time.time()
705+
self.assertRaises(pyqueue.Empty, q.get, True, 0.2)
706+
delta = time.time() - start
707+
self.assertGreaterEqual(delta, 0.19)
708+
702709
#
703710
#
704711
#

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ Core and Builtins
4242
Library
4343
-------
4444

45+
- Issue #17707: multiprocessing.Queue's get() method does not block for short
46+
timeouts.
47+
4548
- Issue #17012: shutil.which() no longer fallbacks to the PATH environment
4649
variable if empty path argument is specified. Patch by Serhiy Storchaka.
4750

0 commit comments

Comments
 (0)