Skip to content

Commit

Permalink
Intersect TaskGroup states and ALL_TASK_STATES
Browse files Browse the repository at this point in the history
As `dict.values` supports intersections and `ALL_TASK_STATES` is a
`set`, we can just compute their intersection directly. This winds up
being significantly faster and simpler.
  • Loading branch information
jakirkham committed Jan 24, 2021
1 parent 7d2a080 commit 89a84e5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion distributed/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5908,7 +5908,7 @@ def transition(self, key, finish: str, *args, **kwargs):
tg: TaskGroup = ts._group
if ts._state == "forgotten" and tg._name in parent._task_groups:
# Remove TaskGroup if all tasks are in the forgotten state
if not any([tg._states.get(s) for s in ALL_TASK_STATES]):
if not (tg._states.values() & ALL_TASK_STATES):
ts._prefix._groups.remove(tg)
del parent._task_groups[tg._name]

Expand Down

0 comments on commit 89a84e5

Please sign in to comment.