本文整理汇总了Python中mo_logs.Log.fatal方法的典型用法代码示例。如果您正苦于以下问题:Python Log.fatal方法的具体用法?Python Log.fatal怎么用?Python Log.fatal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mo_logs.Log
的用法示例。
在下文中一共展示了Log.fatal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _run
# 需要导入模块: from mo_logs import Log [as 别名]
# 或者: from mo_logs.Log import fatal [as 别名]
def _run(self):
self.id = get_ident()
with RegisterThread(self):
try:
if self.target is not None:
a, k, self.args, self.kwargs = self.args, self.kwargs, None, None
self.end_of_thread.response = self.target(*a, **k)
self.parent.remove_child(self) # IF THREAD ENDS OK, THEN FORGET ABOUT IT
except Exception as e:
e = Except.wrap(e)
with self.synch_lock:
self.end_of_thread.exception = e
with self.parent.child_lock:
emit_problem = self not in self.parent.children
if emit_problem:
# THREAD FAILURES ARE A PROBLEM ONLY IF NO ONE WILL BE JOINING WITH IT
try:
Log.fatal("Problem in thread {{name|quote}}", name=self.name, cause=e)
except Exception:
sys.stderr.write(str("ERROR in thread: " + self.name + " " + text_type(e) + "\n"))
finally:
try:
with self.child_lock:
children = copy(self.children)
for c in children:
try:
DEBUG and sys.stdout.write(str("Stopping thread " + c.name + "\n"))
c.stop()
except Exception as e:
Log.warning("Problem stopping thread {{thread}}", thread=c.name, cause=e)
for c in children:
try:
DEBUG and sys.stdout.write(str("Joining on thread " + c.name + "\n"))
c.join()
except Exception as e:
Log.warning("Problem joining thread {{thread}}", thread=c.name, cause=e)
finally:
DEBUG and sys.stdout.write(str("Joined on thread " + c.name + "\n"))
del self.target, self.args, self.kwargs
DEBUG and Log.note("thread {{name|quote}} stopping", name=self.name)
except Exception as e:
DEBUG and Log.warning("problem with thread {{name|quote}}", cause=e, name=self.name)
finally:
self.stopped.go()
DEBUG and Log.note("thread {{name|quote}} is done", name=self.name)