Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
crusaderky committed Oct 15, 2021
1 parent 84c08ef commit d731381
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions distributed/worker.py
Expand Up @@ -911,9 +911,9 @@ def executor(self):
def status(self, value):
"""Override Server.status to notify the Scheduler of status changes"""
ServerNode.status.__set__(self, value)
self._send_worker_status()
self._send_worker_status_change()

def _send_worker_status(self) -> None:
def _send_worker_status_change(self) -> None:
if (
self.batched_stream
and self.batched_stream.comm
Expand All @@ -923,7 +923,7 @@ def _send_worker_status(self) -> None:
{"op": "worker-status-change", "status": self._status.name}
)
elif self._status != Status.closed:
self.loop.call_later(0.05, self._send_worker_status)
self.loop.call_later(0.05, self._send_worker_status_change)

async def get_metrics(self):
out = dict(
Expand Down Expand Up @@ -3696,7 +3696,11 @@ def get_worker() -> Worker:
return thread_state.execution_state["worker"]
except AttributeError:
try:
return first(w for w in Worker._instances if w.status in RUNNING)
return first(
w
for w in Worker._instances
if w.status in (Status.running, Status.paused)
)
except StopIteration:
raise ValueError("No workers found")

Expand Down

0 comments on commit d731381

Please sign in to comment.