Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/helpermodules/utils/_thread_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from threading import Thread, enumerate
import time
from typing import List, Optional

log = logging.getLogger(__name__)
Expand All @@ -26,9 +27,16 @@ def split_chunks(to_split, n):
for thread in threads_to_keep:
thread.start()

# Wait for all to complete
for thread in threads_to_keep:
thread.join(timeout=timeout)
if threads_to_keep:
if timeout is not None:
start_time = time.monotonic()
while time.monotonic() - start_time < timeout:
if not [t for t in threads_to_keep if t.is_alive()]:
break
time.sleep(0.05)
else:
for thread in threads_to_keep:
thread.join()

for thread in threads_to_keep:
if thread.is_alive():
Expand Down