def LockActionsThreadProc(cls): lock = threading.Lock() for _ in range(1000): _fork_locking.acquire_lock() try: with lock: time.sleep(0.001) logging.debug("lock action done") with cls.LockActionsGuard: cls.LockActionsCounter += 1 finally: _fork_locking.release_lock() time.sleep(0.001)
def acquire_restore_lock(lock, count_owner): _fork_locking.acquire_lock() return lock._acquire_restore(count_owner)
def acquire_lock(lock, blocking=True): if not blocking: raise RuntimeError("Non-blocking acquire not implemented") _fork_locking.acquire_lock() return lock.acquire()