MCPcopy
hub / github.com/Open-Wine-Components/umu-launcher / unix_flock

Function unix_flock

umu/umu_util.py:50–62  ·  view source on GitHub ↗

Create a file and configure it to be locking.

(path: str)

Source from the content-addressed store, hash-verified

48
49@contextmanager
50def unix_flock(path: str):
51 """Create a file and configure it to be locking."""
52 fd: int | None = None
53
54 try:
55 fd = os.open(path, os.O_CREAT | os.O_WRONLY, 0o644)
56 # See https://man7.org/linux/man-pages/man2/flock.2.html
57 flock(fd, LOCK_EX)
58 yield fd
59 finally:
60 if fd is not None:
61 flock(fd, LOCK_UN)
62 os.close(fd)
63
64
65@contextmanager

Callers 5

umu_runFunction · 0.90
_get_latestFunction · 0.90
_get_deltaFunction · 0.90
_restore_umuFunction · 0.90
_update_umu_platformFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected