[tor-commits] [sbws/master] scanner: log any exception raised by main_loop
juga at torproject.org
juga at torproject.org
Thu Feb 28 11:09:52 UTC 2019
commit 88752c93de820fce8b1e6486984da117f68a0b93
Author: juga0 <juga at riseup.net>
Date: Wed Feb 27 15:08:55 2019 +0000
scanner: log any exception raised by main_loop
before stopping the scanner.
---
sbws/core/scanner.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/sbws/core/scanner.py b/sbws/core/scanner.py
index 00071be..a1206d3 100644
--- a/sbws/core/scanner.py
+++ b/sbws/core/scanner.py
@@ -36,6 +36,9 @@ pool = None
rd = None
controller = None
+FILLUP_TICKET_MSG = """Something went wrong.
+Please create a ticket in https://trac.torproject.org with this traceback."""
+
def stop_threads(signal, frame, exit_code=0):
global rd, pool
@@ -540,14 +543,18 @@ def run_speedtest(args, conf):
fail_hard(error_msg)
max_pending_results = conf.getint('scanner', 'measurement_threads')
pool = Pool(max_pending_results)
-
try:
main_loop(args, conf, controller, rl, cb, rd, rp, destinations,
max_pending_results, pool)
except KeyboardInterrupt:
log.info("Interrupted by the user.")
- finally:
stop_threads(signal.SIGINT, None)
+ # Any exception not catched at this point would make the scanner stall.
+ # Log it and exit gracefully.
+ except Exception as e:
+ log.critical(FILLUP_TICKET_MSG)
+ log.exception(e)
+ stop_threads(signal.SIGTERM, None, 1)
def gen_parser(sub):
More information about the tor-commits
mailing list