Log thread's error instead of stopping the whole queue.

This commit is contained in:
voussoir 2022-08-14 10:43:13 -07:00
parent 54281d52c2
commit 2318b978c9
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -5,6 +5,7 @@ import shutil
import sys
import threading
import time
import traceback
from voussoirkit import betterhelp
from voussoirkit import bytestring
@ -175,14 +176,15 @@ def threaded_dl(
kwargss.append(kwargs)
pool.add_many(kwargss)
status = 0
for job in pool.result_generator():
if job.exception:
ui_stop_event.set()
ui_thread.join()
raise job.exception
log.error(traceback.format_exc())
status = 1
ui_stop_event.set()
ui_thread.join()
return status
def ui_thread_func(meter, pool, stop_event):
if pipeable.stdout_pipe():
@ -207,7 +209,7 @@ def threaded_dl_argparse(args):
if bytespersecond is not None:
bytespersecond = bytestring.parsebytes(bytespersecond)
threaded_dl(
return threaded_dl(
urls,
bytespersecond=bytespersecond,
filename_format=args.filename_format,
@ -216,8 +218,6 @@ def threaded_dl_argparse(args):
timeout=args.timeout,
)
return 0
@vlogging.main_decorator
def main(argv):
parser = argparse.ArgumentParser()