diff --git a/src/wf_scheduling/lifecycle.py b/src/wf_scheduling/lifecycle.py index b81699f1..fc0fb846 100644 --- a/src/wf_scheduling/lifecycle.py +++ b/src/wf_scheduling/lifecycle.py @@ -516,7 +516,10 @@ class SchedulerService: cancelled = False while not self._lock.acquire(blocking=False): try: - await asyncio.sleep(0) + # The poll worker may hold this lock during file I/O. A + # nonzero delay avoids busy-spinning the event loop while + # still allowing registration and stop callbacks to run. + await asyncio.sleep(0.001) except asyncio.CancelledError: if not continue_after_cancel: raise