mirror of https://github.com/devine-dl/devine.git
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:
parent
51fb7920c9
commit
9cfda3bb9c
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue