Skip to content

Commit b06488f

Browse files
authored
Trivial tweaks to the Worker State Machine (dask#6586)
1 parent 2ce46ec commit b06488f

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

distributed/tests/test_worker_state_machine.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ def test_TaskState__to_dict():
8484

8585

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

105104
expect = {
106-
"address": "127.0.0.1.1234",
105+
"address": "127.0.0.1:1234",
107106
"busy_workers": [],
108107
"constrained": [],
109108
"data": {"y": None},
@@ -119,7 +118,7 @@ def test_WorkerState__to_dict():
119118
["y", "receive-from-scatter", "s2"],
120119
],
121120
"long_running": [],
122-
"nthreads": 8,
121+
"nthreads": 1,
123122
"ready": [],
124123
"running": True,
125124
"stimulus_log": [

distributed/worker_state_machine.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ def __repr__(self) -> str:
276276
return f"<TaskState {self.key!r} {self.state}>"
277277

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

285285
def __hash__(self) -> int:
@@ -1031,8 +1031,8 @@ class WorkerState:
10311031

10321032
def __init__(
10331033
self,
1034-
nthreads: int,
10351034
*,
1035+
nthreads: int = 1,
10361036
address: str | None = None,
10371037
data: MutableMapping[str, Any] = None,
10381038
threads: dict[str, int] | None = None,

0 commit comments

Comments
 (0)