Handle download worker exceptions outside thread loop

This is so that I can start to log information after the track listing. It's also not necessary to have the try catch within the loop, when both methods will have exited the loop.
This commit is contained in:
rlaphoenix 2023-03-01 10:02:38 +00:00
parent 624bb6fe75
commit fbe78308eb
1 changed files with 13 additions and 7 deletions

View File

@ -34,6 +34,7 @@ from rich.rule import Rule
from rich.table import Table
from rich.text import Text
from rich.tree import Tree
from rich.console import Group
from devine.core.config import config
from devine.core.console import console
@ -474,19 +475,24 @@ class dl:
)
for i, track in enumerate(title.tracks)
)):
try:
download.result()
except Exception: # noqa
self.DL_POOL_STOP.set()
self.log.error("Download worker threw an unhandled exception:")
console.print_exception()
return
except KeyboardInterrupt:
console.print(Padding(
":x: Download Cancelled...",
(0, 5, 1, 5)
))
return
except Exception: # noqa
console.print_exception()
console.print(Padding(
Group(
":x: Download Failed...",
" One of the download workers had an error!",
" See the error trace above for more information."
),
(1, 5)
))
return
video_track_n = 0