Commit 0c2e0509 authored by Ralf's avatar Ralf
Browse files

try to be more resilient against top-level exceptions... or, at least, get the error out there

parent 4ea772dc
......@@ -28,33 +28,37 @@ else:
logger.info("Starting up...")
# initialize i2c stuff
i2c = I2C(1)
try:
i2c = I2C(1)
# bring 'em all up
the_actor = actor.Actor(i2c)
the_led_actor = ledactor.LedActor(i2c)
the_waker = waker.Waker()
the_api = spaceapi.SpaceApi(the_waker)
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)
# bring 'em all up
the_actor = actor.Actor(i2c)
the_led_actor = ledactor.LedActor(i2c)
the_waker = waker.Waker()
the_api = spaceapi.SpaceApi(the_waker)
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)
# tell the i2c that all initial values are set
i2c.activate()
# tell the i2c that all initial values are set
i2c.activate()
# we do the socket accept thing in the main thread
try:
the_socket.accept()
except KeyboardInterrupt:
# this is what we waited for!
pass
logger.info("Terminating...") # somehow this does not arrive in the syslog
# bring 'em all down
the_waker.stop() # this one first, it "randomly" calls other threads
the_pins.stop() # as does this
the_machine.stop()
the_api.stop()
the_actor.stop()
the_led_actor.stop()
# we do the socket accept thing in the main thread
try:
the_socket.accept()
except KeyboardInterrupt:
# this is what we waited for!
pass
logger.info("Terminating...") # somehow this does not arrive in the syslog
# bring 'em all down
the_waker.stop() # this one first, it "randomly" calls other threads
the_pins.stop() # as does this
the_machine.stop()
the_api.stop()
the_actor.stop()
the_led_actor.stop()
except e:
# 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%s" % (self.name, 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