Skip to content

Commit

Permalink
Don't let no-worker and long-running tasks break Computations
Browse files Browse the repository at this point in the history
  • Loading branch information
crusaderky committed Apr 19, 2023
1 parent eb531b3 commit 57b8868
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion distributed/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,19 @@ def _clear_task_state(self) -> None:
):
collection.clear() # type: ignore

@property
def fully_idle(self) -> bool:
"""Return True iff there are no tasks that haven't finished computing.
Unlike testing `self.total_occupancy`, this property returns False if there are
long-running tasks, no-worker, or queued tasks (due to not having any workers).
"""
return all(
count == 0 or state in {"memory", "error", "released", "forgotten"}
for tg in self.task_groups.values()
for state, count in tg.states.items()
)

@property
def total_occupancy(self) -> float:
return self._calc_occupancy(
Expand Down Expand Up @@ -4319,7 +4332,7 @@ def update_graph(
keys=lost_keys, client=client, stimulus_id=stimulus_id
)

if self.total_occupancy > 1e-9 and self.computations:
if not self.fully_idle and self.computations:
# Still working on something. Assign new tasks to same computation
computation = self.computations[-1]
else:
Expand Down

0 comments on commit 57b8868

Please sign in to comment.