當前位置: 首頁>>代碼示例>>Python>>正文


Python threading._limbo方法代碼示例

本文整理匯總了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 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:27,代碼來源:background_thread.py

示例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() 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:20,代碼來源:background_thread.py

示例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 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:16,代碼來源:test_threading.py

示例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 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:16,代碼來源:test_threading.py

示例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() 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:17,代碼來源:background_thread.py


注:本文中的threading._limbo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。