def ForkActionsThreadProc(cls): for _ in range(1000): _fork_locking.acquire_fork() try: pid = os.fork() if pid == 0: with cls.LockActionsGuard: logging.debug("LockActionsCounter value is %d", cls.LockActionsCounter) os._exit(0) assert pid > 0 os.waitpid(pid, 0) cls.ForkActionsCounter += 1 finally: _fork_locking.release_fork() time.sleep(0.001)
def acquire_fork(): _fork_locking.acquire_fork()