Skip to content

Commit

Permalink
Trivial tweaks to the Worker State Machine (#6586)
Browse files Browse the repository at this point in the history
  • Loading branch information
crusaderky authored Jun 17, 2022
1 parent 2ce46ec commit b06488f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions distributed/tests/test_worker_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ def test_TaskState__to_dict():


def test_WorkerState__to_dict():
ws = WorkerState(8)
ws.address = "127.0.0.1.1234"
ws = WorkerState(address="127.0.0.1:1234", transition_counter_max=10)
ws.handle_stimulus(
AcquireReplicasEvent(
who_has={"x": ["127.0.0.1:1235"]}, nbytes={"x": 123}, stimulus_id="s1"
Expand All @@ -103,7 +102,7 @@ def test_WorkerState__to_dict():
del stim["handled"]

expect = {
"address": "127.0.0.1.1234",
"address": "127.0.0.1:1234",
"busy_workers": [],
"constrained": [],
"data": {"y": None},
Expand All @@ -119,7 +118,7 @@ def test_WorkerState__to_dict():
["y", "receive-from-scatter", "s2"],
],
"long_running": [],
"nthreads": 8,
"nthreads": 1,
"ready": [],
"running": True,
"stimulus_log": [
Expand Down
10 changes: 5 additions & 5 deletions distributed/worker_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ def __repr__(self) -> str:
return f"<TaskState {self.key!r} {self.state}>"

def __eq__(self, other: object) -> bool:
# A task may be forgotten and a new TaskState object with the same key may be created in
# its place later on. In the Worker state, you should never have multiple TaskState objects with
# the same key. We can't assert it here however, as this comparison is also used in WeakSets
# for instance tracking purposes.
# A task may be forgotten and a new TaskState object with the same key may be
# created in its place later on. In the Worker state, you should never have
# multiple TaskState objects with the same key. We can't assert it here however,
# as this comparison is also used in WeakSets for instance tracking purposes.
return other is self

def __hash__(self) -> int:
Expand Down Expand Up @@ -1031,8 +1031,8 @@ class WorkerState:

def __init__(
self,
nthreads: int,
*,
nthreads: int = 1,
address: str | None = None,
data: MutableMapping[str, Any] = None,
threads: dict[str, int] | None = None,
Expand Down

0 comments on commit b06488f

Please sign in to comment.