Commit 19e2a285 authored by Ralf's avatar Ralf
Browse files

top-level exceptions, part 5

parent 2cbe5e68
......@@ -95,7 +95,7 @@ class ThreadFunction():
self.name = name
self._f = f
self._q = queue.Queue()
self._t = threading.Thread(target=self._thread_func)
self._t = threading.Thread(target=self._thread_func, daemon=True)
self._t.start()
def _thread_func(self):
......
......@@ -39,7 +39,12 @@ try:
the_machine = statemachine.StateMachine(the_actor, the_led_actor, the_waker, the_api, args.fallback)
the_socket = tysock.TySocket(the_machine)
the_pins = pins.PinsWatcher(the_machine,i2c)
except:
# Make sure we log the error
logger.critical("FATAL TOP-LEVEL EXCEPTION DURING BOOT:\n{}".format(traceback.format_exc()))
sys.exit(1) # go away
try:
# tell the i2c that all initial values are set
i2c.activate()
......@@ -51,7 +56,12 @@ try:
pass
logger.info("Terminating...") # somehow this does not arrive in the syslog
except:
# Make sure we log the error
logger.critical("FATAL TOP-LEVEL EXCEPTION DURING OPERATION:\n{}".format(traceback.format_exc()))
# fall-through to shutdown code
try:
# bring 'em all down
the_waker.stop() # this one first, it "randomly" calls other threads
the_pins.stop() # as does this
......@@ -60,6 +70,5 @@ try:
the_actor.stop()
the_led_actor.stop()
except:
# Make sure we log the error and terminate. Otherwise, some random thread that still runs may prevent us from terminating.
logger.critical("FATAL TOP-LEVEL EXCEPTION:\n{}".format(traceback.format_exc()))
sys.exit(1)
# Make sure we log the error
logger.critical("FATAL TOP-LEVEL EXCEPTION DURING SHUTDOWN:\n{}".format(traceback.format_exc()))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment