本文整理汇总了Python中thread.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python thread.__init__方法的具体用法?Python thread.__init__怎么用?Python thread.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thread
的用法示例。
在下文中一共展示了thread.__init__方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import thread [as 别名]
# 或者: from thread import __init__ [as 别名]
def __init__(self, lock=None, verbose=None):
_Verbose.__init__(self, verbose)
if lock is None:
lock = RLock()
self.__lock = lock
# Export the lock's acquire() and release() methods
self.acquire = lock.acquire
self.release = lock.release
# If the lock defines _release_save() and/or _acquire_restore(),
# these override the default implementations (which just call
# release() and acquire() on the lock). Ditto for _is_owned().
try:
self._release_save = lock._release_save
except AttributeError:
pass
try:
self._acquire_restore = lock._acquire_restore
except AttributeError:
pass
try:
self._is_owned = lock._is_owned
except AttributeError:
pass
self.__waiters = []
示例2: _reset_internal_locks
# 需要导入模块: import thread [as 别名]
# 或者: from thread import __init__ [as 别名]
def _reset_internal_locks(self):
# private! called by Thread._reset_internal_locks by _after_fork()
self.__cond.__init__()
示例3: __repr__
# 需要导入模块: import thread [as 别名]
# 或者: from thread import __init__ [as 别名]
def __repr__(self):
assert self.__initialized, "Thread.__init__() was not called"
status = "initial"
if self.__started.is_set():
status = "started"
if self.__stopped:
status = "stopped"
if self.__daemonic:
status += " daemon"
if self.__ident is not None:
status += " %s" % self.__ident
return "<%s(%s, %s)>" % (self.__class__.__name__, self.__name, status)
示例4: join
# 需要导入模块: import thread [as 别名]
# 或者: from thread import __init__ [as 别名]
def join(self, timeout=None):
if not self.__initialized:
raise RuntimeError("Thread.__init__() not called")
if not self.__started.is_set():
raise RuntimeError("cannot join thread before it is started")
if self is current_thread():
raise RuntimeError("cannot join current thread")
if __debug__:
if not self.__stopped:
self._note("%s.join(): waiting until thread stops", self)
self.__block.acquire()
try:
if timeout is None:
while not self.__stopped:
self.__block.wait()
if __debug__:
self._note("%s.join(): thread stopped", self)
else:
deadline = _time() + timeout
while not self.__stopped:
delay = deadline - _time()
if delay <= 0:
if __debug__:
self._note("%s.join(): timed out", self)
break
self.__block.wait(delay)
else:
if __debug__:
self._note("%s.join(): thread stopped", self)
finally:
self.__block.release()
示例5: name
# 需要导入模块: import thread [as 别名]
# 或者: from thread import __init__ [as 别名]
def name(self):
assert self.__initialized, "Thread.__init__() not called"
return self.__name
示例6: ident
# 需要导入模块: import thread [as 别名]
# 或者: from thread import __init__ [as 别名]
def ident(self):
assert self.__initialized, "Thread.__init__() not called"
return self.__ident
示例7: isAlive
# 需要导入模块: import thread [as 别名]
# 或者: from thread import __init__ [as 别名]
def isAlive(self):
assert self.__initialized, "Thread.__init__() not called"
return self.__started.is_set() and not self.__stopped
示例8: daemon
# 需要导入模块: import thread [as 别名]
# 或者: from thread import __init__ [as 别名]
def daemon(self, daemonic):
if not self.__initialized:
raise RuntimeError("Thread.__init__() not called")
if self.__started.is_set():
raise RuntimeError("cannot set daemon status of active thread");
self.__daemonic = daemonic
示例9: _reset_internal_locks
# 需要导入模块: import thread [as 别名]
# 或者: from thread import __init__ [as 别名]
def _reset_internal_locks(self):
# private! called by Thread._reset_internal_locks by _after_fork()
self.__cond.__init__(Lock())