diff options
author | Magnus Ahltorp <map@kth.se> | 2014-11-18 15:46:23 +0100 |
---|---|---|
committer | Magnus Ahltorp <map@kth.se> | 2014-11-18 15:46:23 +0100 |
commit | 5e49a9a62ee49eb5d882f4ba4221eb72ad72777a (patch) | |
tree | 1a60ee7c73bdb7d565a453fdc62be56fc0fa0d41 | |
parent | 87e02103ea3f47b825b415c415f7d2940d009b42 (diff) |
Catch ctrl-c more correctly. Catch SystemExit from add_chain and exit in main process insteadsubmitcertfix
-rwxr-xr-x | tools/submitcert.py | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/tools/submitcert.py b/tools/submitcert.py index 80a3e37..2bb0c1a 100755 --- a/tools/submitcert.py +++ b/tools/submitcert.py @@ -13,6 +13,7 @@ import hashlib import itertools from certtools import * import os +import signal from multiprocessing import Pool @@ -32,7 +33,10 @@ def submitcert(certfile): certs = get_certs_from_file(certfile) timing_point(timing, "readcerts") - result = add_chain(baseurl, {"chain":map(base64.b64encode, certs)}) + try: + result = add_chain(baseurl, {"chain":map(base64.b64encode, certs)}) + except SystemExit: + return None timing_point(timing, "addchain") @@ -42,10 +46,13 @@ def submitcert(certfile): timing_point(timing, "checksig") except AssertionError, e: print "ERROR:", e - sys.exit(1) + return None + except urllib2.HTTPError, e: + print "ERROR:", e + return None except ecdsa.keys.BadSignatureError, e: print "ERROR: bad signature" - sys.exit(1) + return None if lookup_in_log: @@ -91,8 +98,15 @@ def submitcert(certfile): timing_point(timing, "lookup") return timing["deltatimes"] -p = Pool(1) - -for timing in p.imap_unordered(submitcert, certfiles): - print timing - +p = Pool(1, lambda: signal.signal(signal.SIGINT, signal.SIG_IGN)) + +try: + for timing in p.imap_unordered(submitcert, certfiles): + if timing == None: + p.terminate() + p.join() + sys.exit(1) + print timing +except KeyboardInterrupt: + p.terminate() + p.join() |