sched: require proven ownership at poll/admin/recovery entries (F5)
This commit is contained in:
@@ -39,6 +39,16 @@ class SchedulerOwnership:
|
||||
def lock_path(self) -> Path:
|
||||
return self.root / "scheduler.lock"
|
||||
|
||||
@property
|
||||
def held(self) -> bool:
|
||||
"""Whether this process holds the lock through this object.
|
||||
|
||||
Only a successful :meth:`acquire` sets this: a second process can
|
||||
never observe ``held`` while another owner holds the OS lock, so
|
||||
entry-point guards can treat it as proof of exclusive ownership.
|
||||
"""
|
||||
return self._locked
|
||||
|
||||
def acquire(self) -> SchedulerOwnership:
|
||||
"""Acquire the held lock non-blockingly or raise SecondOwnerError."""
|
||||
self.lock_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user