I’m having an issue with some of my worker threads. I’ve added a catchall exception statement in the thread’s run method like so:
try:
"""Runs the worker process, which is a state machine"""
while self._set_exitcode is None :
assert self._state in Worker.STATES
state_methodname = "_state_%s" % self._state
assert hasattr(self, state_methodname)
state_method = getattr(self, state_methodname)
self._state = state_method() # execute method for current state
self._stop_heartbeat()
sys.exit( self._set_exitcode )
except:
self.log.debug(sys.exc_info())
I read this was the defacto way to catch everything that may be causing an issue instead of using Exception, e. I’ve found some great little bugs thanks to this method but my problem is that the workers’ are still dying and I’m not sure how to further record what’s going on or troubleshoot.
Any thoughts would be greatly appreciated.
Thanks!
You could try examining the execution trace of your program using the
tracemodule. For example:Source:
It will dump out each line as it is executed, and you should get a coverage report in the
coveragedirectory: