Skip to content

Commit

Permalink
Grab func for finish case only if used
Browse files Browse the repository at this point in the history
The transition `func` that was being grabbed depended on whether `key`
was found in the recommendations from the last transition. If `key` was
found, one function based on `v` was called. If not, `finish` was used
in place of `v`. To make this a bit more explicit, simple, and
efficient, assign `finish` to `v` if `key` is not found. This way `v`
can be used in all cases with one call to retrieve the `func`.
  • Loading branch information
jakirkham committed Apr 14, 2021
1 parent feb5285 commit 1d3025f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions distributed/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1885,16 +1885,15 @@ def _transition(
a: tuple = func(key, *args, **kwargs)
recommendations, client_msgs, worker_msgs = a
elif "released" not in start_finish:
func = self._transitions_table["released", finish]
assert not args and not kwargs
a_recs: dict
a_cmsgs: dict
a_wmsgs: dict
a: tuple = self._transition(key, "released")
a_recs, a_cmsgs, a_wmsgs = a
v = a_recs.get(key)
if v is not None:
func = self._transitions_table["released", v]

v = a_recs.get(key, finish)
func = self._transitions_table["released", v]
b_recs: dict
b_cmsgs: dict
b_wmsgs: dict
Expand Down

0 comments on commit 1d3025f

Please sign in to comment.