def stop_backend(sig, frame): backend.terminate() sys.exit(127)
for line in config.listfile[0].readlines(): url_list.append(line) config.listfile[0].close() if config.url: url_list.extend(config.url) if not url_list: arg_parser.print_help() print("No url to download") exit(3) from plugins.disk import get_class from plugins.backend import backend, task_status # Trap SIGINT and SIFTERM def stop_backend(sig, frame): backend.terminate() sys.exit(127) signal.signal(signal.SIGINT, stop_backend) signal.signal(signal.SIGTERM, stop_backend) # start main loop try: main_loop(url_list) except Exception as e: print("Well, sonething went wrong...") backend.terminate() traceback.print_exc()