本文整理汇总了Python中threading._limbo方法的典型用法代码示例。如果您正苦于以下问题:Python threading._limbo方法的具体用法?Python threading._limbo怎么用?Python threading._limbo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threading
的用法示例。
在下文中一共展示了threading._limbo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __bootstrap
# 需要导入模块: import threading [as 别名]
# 或者: from threading import _limbo [as 别名]
def __bootstrap(self):
try:
self._set_ident()
self._Thread__started.set()
threading._active_limbo_lock.acquire()
threading._active[self._Thread__ident] = self
del threading._limbo[self]
threading._active_limbo_lock.release()
if threading._trace_hook:
sys.settrace(threading._trace_hook)
if threading._profile_hook:
sys.setprofile(threading._profile_hook)
try:
self.run()
finally:
self._Thread__exc_clear()
finally:
with threading._active_limbo_lock:
self._Thread__stop()
try:
del threading._active[threading._get_ident()]
except:
pass
示例2: start
# 需要导入模块: import threading [as 别名]
# 或者: from threading import _limbo [as 别名]
def start(self):
"""Starts this background thread."""
_capture_environ()
if not self._Thread__initialized:
raise RuntimeError('thread.__init__() not called')
if self._Thread__started.is_set():
raise RuntimeError('threads can only be started once')
with threading._active_limbo_lock:
threading._limbo[self] = self
try:
start_new_background_thread(self._Thread__bootstrap, ())
except Exception:
with threading._active_limbo_lock:
del threading._limbo[self]
raise
self._Thread__started.wait()
示例3: test_limbo_cleanup
# 需要导入模块: import threading [as 别名]
# 或者: from threading import _limbo [as 别名]
def test_limbo_cleanup(self):
# Issue 7481: Failure to start thread should cleanup the limbo map.
def fail_new_thread(*args):
raise thread.error()
_start_new_thread = threading._start_new_thread
threading._start_new_thread = fail_new_thread
try:
t = threading.Thread(target=lambda: None)
self.assertRaises(thread.error, t.start)
self.assertFalse(
t in threading._limbo,
"Failed to cleanup _limbo map on failure of Thread.start().")
finally:
threading._start_new_thread = _start_new_thread
示例4: test_limbo_cleanup
# 需要导入模块: import threading [as 别名]
# 或者: from threading import _limbo [as 别名]
def test_limbo_cleanup(self):
# Issue 7481: Failure to start thread should cleanup the limbo map.
def fail_new_thread(*args):
raise threading.ThreadError()
_start_new_thread = threading._start_new_thread
threading._start_new_thread = fail_new_thread
try:
t = threading.Thread(target=lambda: None)
self.assertRaises(threading.ThreadError, t.start)
self.assertFalse(
t in threading._limbo,
"Failed to cleanup _limbo map on failure of Thread.start().")
finally:
threading._start_new_thread = _start_new_thread
示例5: start
# 需要导入模块: import threading [as 别名]
# 或者: from threading import _limbo [as 别名]
def start(self):
"""Starts this background thread."""
if not self._Thread__initialized:
raise RuntimeError('thread.__init__() not called')
if self._Thread__started.is_set():
raise RuntimeError('threads can only be started once')
with threading._active_limbo_lock:
threading._limbo[self] = self
try:
start_new_background_thread(self.__bootstrap, ())
except Exception:
with threading._active_limbo_lock:
del threading._limbo[self]
raise
self._Thread__started.wait()