MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _try_skill_lock

Function _try_skill_lock

graphify/install.py:71–87  ·  view source on GitHub ↗

Take the lock on ``fh`` without waiting; False if another process holds it. Raises OSError when the file system cannot lock at all (e.g. some network mounts).

(fh)

Source from the content-addressed store, hash-verified

69
70
71def _try_skill_lock(fh) -> bool:
72 """Take the lock on ``fh`` without waiting; False if another process holds it.
73
74 Raises OSError when the file system cannot lock at all (e.g. some network
75 mounts).
76 """
77 try:
78 if fcntl is not None:
79 fcntl.flock(fh.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
80 else:
81 fh.seek(0)
82 msvcrt.locking(fh.fileno(), msvcrt.LK_NBLCK, 1)
83 except OSError as exc:
84 if exc.errno in (errno.EAGAIN, errno.EWOULDBLOCK, errno.EACCES):
85 return False
86 raise
87 return True
88
89
90def _release_skill_lock(fh) -> None:

Callers 1

_skill_lockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected