From 2318b978c9ad45dc10edd192231f855ae0937fa0 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 14 Aug 2022 10:43:13 -0700 Subject: [PATCH] Log thread's error instead of stopping the whole queue. --- threaded_dl.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/threaded_dl.py b/threaded_dl.py index 7694f2d..5c585ac 100644 --- a/threaded_dl.py +++ b/threaded_dl.py @@ -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()