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.
This commit is contained in:
rlaphoenix 2023-02-28 16:42:45 +00:00
parent 51fb7920c9
commit 9cfda3bb9c
3 changed files with 0 additions and 12 deletions

View File

@ -473,19 +473,15 @@ class dl:
) )
for i, track in enumerate(title.tracks) for i, track in enumerate(title.tracks)
)): )):
if download.cancelled():
continue
try: try:
download.result() download.result()
except Exception: # noqa except Exception: # noqa
self.DL_POOL_STOP.set() self.DL_POOL_STOP.set()
pool.shutdown(wait=False, cancel_futures=True)
self.log.error("Download worker threw an unhandled exception:") self.log.error("Download worker threw an unhandled exception:")
console.print_exception() console.print_exception()
return return
except KeyboardInterrupt: except KeyboardInterrupt:
self.DL_POOL_STOP.set() self.DL_POOL_STOP.set()
pool.shutdown(wait=False, cancel_futures=True)
self.log.info("Received Keyboard Interrupt, stopping...") self.log.info("Received Keyboard Interrupt, stopping...")
return return

View File

@ -520,12 +520,9 @@ class DASH:
for i, segment in enumerate(segments) for i, segment in enumerate(segments)
)): )):
finished_threads += 1 finished_threads += 1
if download.cancelled():
continue
e = download.exception() e = download.exception()
if e: if e:
state_event.set() state_event.set()
pool.shutdown(wait=False, cancel_futures=True)
traceback.print_exception(e) traceback.print_exception(e)
log.error(f"Segment Download worker threw an unhandled exception: {e!r}") log.error(f"Segment Download worker threw an unhandled exception: {e!r}")
sys.exit(1) sys.exit(1)
@ -547,7 +544,6 @@ class DASH:
download_sizes.clear() download_sizes.clear()
except KeyboardInterrupt: except KeyboardInterrupt:
state_event.set() state_event.set()
pool.shutdown(wait=False, cancel_futures=True)
log.info("Received Keyboard Interrupt, stopping...") log.info("Received Keyboard Interrupt, stopping...")
return return

View File

@ -360,12 +360,9 @@ class HLS:
for i, segment in enumerate(master.segments) for i, segment in enumerate(master.segments)
)): )):
finished_threads += 1 finished_threads += 1
if download.cancelled():
continue
e = download.exception() e = download.exception()
if e: if e:
state_event.set() state_event.set()
pool.shutdown(wait=False, cancel_futures=True)
traceback.print_exception(e) traceback.print_exception(e)
log.error(f"Segment Download worker threw an unhandled exception: {e!r}") log.error(f"Segment Download worker threw an unhandled exception: {e!r}")
sys.exit(1) sys.exit(1)
@ -387,7 +384,6 @@ class HLS:
download_sizes.clear() download_sizes.clear()
except KeyboardInterrupt: except KeyboardInterrupt:
state_event.set() state_event.set()
pool.shutdown(wait=False, cancel_futures=True)
log.info("Received Keyboard Interrupt, stopping...") log.info("Received Keyboard Interrupt, stopping...")
return return