我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用threading._RLock()。
def init(with_threads=1): """Initialize threading. Don't bother calling this. If it needs to happen, it will happen. """ global threaded, _synchLockCreator, XLock if with_threads: if not threaded: if threadmodule is not None: threaded = True class XLock(threadingmodule._RLock, object): def __reduce__(self): return (unpickle_lock, ()) _synchLockCreator = XLock() else: raise RuntimeError("Cannot initialize threading, platform lacks thread support") else: if threaded: raise RuntimeError("Cannot uninitialize threads") else: pass
def init(with_threads=1): """Initialize threading. Don't bother calling this. If it needs to happen, it will happen. """ global threaded, _synchLockCreator, XLock if with_threads: if not threaded: if threadingmodule is not None: threaded = True class XLock(threadingmodule._RLock, object): def __reduce__(self): return (unpickle_lock, ()) _synchLockCreator = XLock() else: raise RuntimeError("Cannot initialize threading, platform lacks thread support") else: if threaded: raise RuntimeError("Cannot uninitialize threads") else: pass
def __init__(self, *args): from OpenSSL import SSL as _ssl self._ssl_conn = apply(_ssl.Connection, args) from threading import _RLock self._lock = _RLock()
def __init__(self): threading._RLock.__init__(self)
def acquire(self, blocking=1): if self._is_owned(): raise NRLockException("Recursive NRLock acquire") return threading._RLock.acquire(self, blocking)
def release(self): try: threading._RLock.release(self) except RuntimeError: errbuf = "Release of unacquired lock\n" errbuf += self._debug_lock_release() raise NRLockException(errbuf)