From 9cfda3bb9c6fb23b32d39a5f24927afe2640a748 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Tue, 28 Feb 2023 16:42:45 +0000 Subject: [PATCH] Don't shutdown pool or the for loop will lock Since I'm using `futures.as_completed()`, it will never ever for loop over all tracks and segments and will forever be stuck in the primary thread of the operation. I.e., main thread for the download track threads, or the track thread for the download segment threads. I've also removed all future cancelled checks as they will never be cancelled before they get the chance to run, because no future cancel calls are made anymore. --- devine/commands/dl.py | 4 ---- devine/core/manifests/dash.py | 4 ---- devine/core/manifests/hls.py | 4 ---- 3 files changed, 12 deletions(-) diff --git a/devine/commands/dl.py b/devine/commands/dl.py index 09c0bee..530541b 100644 --- a/devine/commands/dl.py +++ b/devine/commands/dl.py @@ -473,19 +473,15 @@ class dl: ) for i, track in enumerate(title.tracks) )): - if download.cancelled(): - continue try: download.result() except Exception: # noqa self.DL_POOL_STOP.set() - pool.shutdown(wait=False, cancel_futures=True) self.log.error("Download worker threw an unhandled exception:") console.print_exception() return except KeyboardInterrupt: self.DL_POOL_STOP.set() - pool.shutdown(wait=False, cancel_futures=True) self.log.info("Received Keyboard Interrupt, stopping...") return diff --git a/devine/core/manifests/dash.py b/devine/core/manifests/dash.py index cacb7db..86ebde7 100644 --- a/devine/core/manifests/dash.py +++ b/devine/core/manifests/dash.py @@ -520,12 +520,9 @@ class DASH: for i, segment in enumerate(segments) )): finished_threads += 1 - if download.cancelled(): - continue e = download.exception() if e: state_event.set() - pool.shutdown(wait=False, cancel_futures=True) traceback.print_exception(e) log.error(f"Segment Download worker threw an unhandled exception: {e!r}") sys.exit(1) @@ -547,7 +544,6 @@ class DASH: download_sizes.clear() except KeyboardInterrupt: state_event.set() - pool.shutdown(wait=False, cancel_futures=True) log.info("Received Keyboard Interrupt, stopping...") return diff --git a/devine/core/manifests/hls.py b/devine/core/manifests/hls.py index 75c90f3..0c0b1ba 100644 --- a/devine/core/manifests/hls.py +++ b/devine/core/manifests/hls.py @@ -360,12 +360,9 @@ class HLS: for i, segment in enumerate(master.segments) )): finished_threads += 1 - if download.cancelled(): - continue e = download.exception() if e: state_event.set() - pool.shutdown(wait=False, cancel_futures=True) traceback.print_exception(e) log.error(f"Segment Download worker threw an unhandled exception: {e!r}") sys.exit(1) @@ -387,7 +384,6 @@ class HLS: download_sizes.clear() except KeyboardInterrupt: state_event.set() - pool.shutdown(wait=False, cancel_futures=True) log.info("Received Keyboard Interrupt, stopping...") return