本文整理匯總了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()