def start(self):
if not self.__initialized:
raise RuntimeError("thread.__init__() not called")
if self.__started.is_set():
raise RuntimeError("threads can only be started once")
if __debug__:
self._note("%s.start(): starting thread", self)
with _active_limbo_lock:
_limbo[self] = self
try:
_start_new_thread(self.__bootstrap, ())
except Exception:
with _active_limbo_lock:
# NOTE(google) Added 'in' check. This handles the possibility of
# an asynchronous exception (e.g., DeadlineExceededError) being
# thrown inside of __bootstrap_inner after it removes self from
# _limbo, causing a KeyError to be raised here. It is safe to
# ignore such an error, because it means self has already been
# removed from _limbo.
if self in _limbo:
del _limbo[self]
raise
self.__started.wait()
评论列表
文章目录