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

Class BlockingLock

tests/core/test_fork_construction.py:353–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351 parent_pid = os.getpid()
352
353 class BlockingLock(BaseFileLock):
354 def __init__(self, lock_file: str, *, is_singleton: bool = False) -> None:
355 if os.getpid() == parent_pid:
356 entered.set()
357 release.wait(timeout=5)
358 super().__init__(lock_file, thread_local=False, is_singleton=is_singleton)
359
360 @override
361 def _acquire(self) -> None:
362 self._context.lock_file_fd = os.open(self.lock_file, os.O_CREAT | os.O_RDWR, 0o600)
363
364 @override
365 def _release(self) -> None:
366 os.close(self._context.lock_file_fd if self._context.lock_file_fd is not None else -1)
367 self._context.lock_file_fd = None
368
369 worker = threading.Thread(target=BlockingLock, args=(str(tmp_path / "mutex.lock"),), kwargs={"is_singleton": True})
370 worker.start()

Callers 1

childFunction · 0.85

Calls

no outgoing calls

Tested by 1

childFunction · 0.68