我的一些工作线程出现问题。我在线程的run方法中添加了catchall异常语句,如下所示:
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())
我读到这是捕捉所有可能导致问题的事实方法,而不是使用Exception, e
。由于这个方法,我发现了一些很好的小错误,但我的问题是工人们仍然在死亡,我不知道如何进一步记录正在发生的事情或排除故障。在
任何想法都将不胜感激。在
谢谢!在
是什么让你认为有些线程过早退出?有没有可能它们正在干净地退出,但您的日志记录方法不是线程安全的?在
{你可以试试看。例如:
资料来源:
^{pr2}$它将在执行时转储每一行,您应该在
coverage
目录中获得一个覆盖率报告:相关问题 更多 >
编程相关推荐