Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions distributed/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@
)
from contextlib import suppress
from functools import partial
from typing import TYPE_CHECKING, Any, ClassVar, Literal, NamedTuple, cast, overload
from typing import (
TYPE_CHECKING,
Any,
ClassVar,
Final,
Literal,
NamedTuple,
cast,
overload,
)

import psutil
import tornado.web
Expand Down Expand Up @@ -413,7 +422,7 @@ class WorkerState:

#: This worker's unique key. This can be its connected address
#: (such as ``"tcp://127.0.0.1:8891"``) or an alias (such as ``"alice"``).
address: str
address: Final[str]

pid: int
name: Hashable
Expand Down Expand Up @@ -513,6 +522,9 @@ class WorkerState:
#: on the worker.
needs_what: dict[TaskState, int]

#: The hostname / IP address identifying the machine this worker is on.
host: Final[str]

__slots__ = tuple(__annotations__)

def __init__(
Expand Down Expand Up @@ -564,6 +576,7 @@ def __init__(
self.needs_what = {}
self._network_occ = 0
self._occupancy_cache = None
self.host = get_address_host(self.address)

def __hash__(self) -> int:
return self._hash
Expand All @@ -584,10 +597,6 @@ def has_what(self) -> Set[TaskState]:
"""
return self._has_what.keys()

@property
def host(self) -> str:
return get_address_host(self.address)

@property
def memory(self) -> MemoryState:
"""Polished memory metrics for the worker.
Expand Down
Loading