sched: require proven ownership at poll/admin/recovery entries (F5)

This commit is contained in:
lda
2026-09-08 11:24:40 +07:00 Verified
parent 15bd472bdc
commit 993ed07fd3
7 changed files with 293 additions and 22 deletions
+10
View File
@@ -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)