[core] Cleanly abort on ctrl+c

During debugging, being able to cleanly (i.e. without backtrace) exit
using ctrl+c is a very welcome functionality :)
This commit is contained in:
Tobias Witek 2017-05-13 20:28:11 +02:00
parent f03eada002
commit 9b0c9a49e8

View file

@ -38,6 +38,9 @@ def main():
inp=inp, inp=inp,
) )
engine.run() engine.run()
except KeyboardInterrupt as error:
inp.stop()
sys.exit(0)
except BaseException as e: except BaseException as e:
logging.exception(e) logging.exception(e)
if output.started(): if output.started():
@ -56,18 +59,6 @@ def main():
output.flush() output.flush()
output.end() output.end()
time.sleep(1) time.sleep(1)
# try:
# except KeyboardInterrupt as error:
# inp.stop()
# sys.exit(0)
# except bumblebee.error.BaseError as error:
# inp.stop()
# sys.stderr.write("fatal: {}\n".format(error))
# sys.exit(1)
# except Exception as error:
# inp.stop()
# sys.stderr.write("fatal: {}\n".format(error))
# sys.exit(2)
if __name__ == "__main__": if __name__ == "__main__":
main() main()