Skip to content

Commit a7bacf4

Browse files
committed
Add timeout to JoinableQueue.join
1 parent c527eb1 commit a7bacf4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎Lib/multiprocessing/queues.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,14 @@ def task_done(self):
327327
if self._unfinished_tasks._semlock._is_zero():
328328
self._cond.notify_all()
329329

330-
def join(self):
330+
def join(self, timeout=None) -> None:
331331
with self._cond:
332332
if not self._unfinished_tasks._semlock._is_zero():
333-
self._cond.wait()
333+
self._cond.wait(timeout=timeout)
334+
335+
def is_done(self) -> bool:
336+
with self._cond:
337+
return self._unfinished_tasks._semlock._is_zero()
334338

335339
#
336340
# Simplified Queue type -- really just a locked pipe

0 commit comments

Comments
 (0)