MCPcopy Create free account
hub / github.com/tox-dev/filelock / BlockingLock

Class BlockingLock

tests/test_fork_coordination.py:1136–1148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1134 parent_pid = os.getpid()
1135
1136 class BlockingLock(BaseFileLock):
1137 def __init__(self, lock_file: str, *, is_singleton: bool = False) -> None:
1138 if os.getpid() == parent_pid:
1139 entered.set()
1140 release.wait(timeout=5)
1141 super().__init__(lock_file, thread_local=False, is_singleton=is_singleton)
1142
1143 def _acquire(self) -> None:
1144 self._context.lock_file_fd = os.open(self.lock_file, os.O_CREAT | os.O_RDWR, 0o600)
1145
1146 def _release(self) -> None:
1147 os.close(self._context.lock_file_fd if self._context.lock_file_fd is not None else -1)
1148 self._context.lock_file_fd = None
1149
1150 worker = threading.Thread(target=BlockingLock, args=(str(tmp_path / "mutex.lock"),), kwargs={"is_singleton": True})
1151 worker.start()

Calls

no outgoing calls