sched: gate scheduled resumes on the shared execution slot, with drain tracking (B2)

This commit is contained in:
lda
2026-09-09 17:23:28 +07:00 Verified
parent fd2f85ef96
commit ada0239a1c
8 changed files with 459 additions and 15 deletions
+9 -1
View File
@@ -190,11 +190,19 @@ class Scheduler:
return admission.schedule_id
def _task_load(self) -> int:
from wf_scheduling.recovery import _is_pending
from wf_scheduling.recovery import _is_pending, is_executing
count = 0
for run in self.run_store.list_runs():
if self._status_value(run) != "admitted":
# A mid-resume scheduled run is interrupted but holds the
# durable executing mark: it occupies a live execution
# slot exactly like a dispatched run (B2), so the shared
# capacity gate must count it.
if is_executing(self.run_store, run.id) and not _is_pending(
self.run_store, run.id
):
count += 1
continue
if _is_pending(self.run_store, run.id):
continue