klippy: Improve handling of reactor.run() exceptions
Try to invoke a shutdown on an unhandled exception from reactor.run(). If that fails, try to do a clean exit. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
1cdf0d474d
commit
c285f8b6cf
|
@ -187,8 +187,17 @@ class Printer:
|
||||||
try:
|
try:
|
||||||
self.reactor.run()
|
self.reactor.run()
|
||||||
except:
|
except:
|
||||||
logging.exception("Unhandled exception during run")
|
msg = "Unhandled exception during run"
|
||||||
return "error_exit"
|
logging.exception(msg)
|
||||||
|
# Exception from a reactor callback - try to shutdown
|
||||||
|
try:
|
||||||
|
self.reactor.register_callback((lambda e:
|
||||||
|
self.invoke_shutdown(msg)))
|
||||||
|
self.reactor.run()
|
||||||
|
except:
|
||||||
|
logging.exception("Repeat unhandled exception during run")
|
||||||
|
# Another exception - try to exit
|
||||||
|
self.run_result = "error_exit"
|
||||||
# Check restart flags
|
# Check restart flags
|
||||||
run_result = self.run_result
|
run_result = self.run_result
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue