Skip to content

Commit cc139fb

Browse files
HyangMin Jeongclaude
authored andcommitted
Fix saturation_factor=0 to allow task assignment to idle workers
The previous implementation returned 0 for idle workers when saturation_factor=0, which caused _worker_full() to incorrectly mark idle workers as full (since it checks `<= 0`). This prevented any tasks from being assigned, causing test timeouts. Changed _task_slots_available() to return 1 for idle workers when saturation_factor=0, allowing idle workers to accept tasks while still preventing queuing on busy workers. Behavior with saturation_factor=0: - Idle worker: slots = 1 (can accept tasks) - Worker with 1 task: slots = 0 (marked as full) - Worker with seceded task: slots = 1 (can accept tasks) Fixes test_saturation_factor[0.0-expected_task_counts5] timeout. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 66ed359 commit cc139fb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

distributed/scheduler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9289,7 +9289,7 @@ def _task_slots_available(ws: WorkerState, saturation_factor: float) -> int:
92899289
# Special case: saturation_factor == 0 means no queuing
92909290
# Only send tasks to workers that are completely idle
92919291
if saturation_factor == 0:
9292-
return 0 - (len(ws.processing) - len(ws.long_running))
9292+
return 1 - (len(ws.processing) - len(ws.long_running))
92939293

92949294
return max(math.ceil(saturation_factor * ws.nthreads), 1) - (
92959295
len(ws.processing) - len(ws.long_running)

0 commit comments

Comments
 (0)