Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ repos:
rev: v0.15.2
hooks:
- id: ruff-check
# args: [--fix]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.3.1
hooks:
Expand Down
16 changes: 12 additions & 4 deletions distributed/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ class BaseActorFuture(abc.ABC, Awaitable[_T]):
Actor
"""

__slots__ = ()

@abc.abstractmethod
def result(self, timeout: str | timedelta | float | None = None) -> _T: ...

Expand All @@ -255,7 +257,7 @@ def __repr__(self) -> Literal["<ActorFuture>"]:
return "<ActorFuture>"


@dataclass(frozen=True, eq=False)
@dataclass(frozen=True, eq=False, slots=True)
class EagerActorFuture(BaseActorFuture[_T]):
"""Future to an actor's method call when an actor calls another actor on the same worker"""

Expand All @@ -272,15 +274,15 @@ def done(self) -> Literal[True]:
return True


@dataclass(frozen=True, eq=False)
@dataclass(frozen=True, eq=False, slots=True)
class _OK(Generic[_T]):
_v: _T

def unwrap(self) -> _T:
return self._v


@dataclass(frozen=True, eq=False)
@dataclass(frozen=True, eq=False, slots=True)
class _Error:
_e: Exception

Expand All @@ -289,10 +291,16 @@ def unwrap(self) -> NoReturn:


class ActorFuture(BaseActorFuture[_T]):
_io_loop: IOLoop
_event: LateLoopEvent
_out: _Error | _OK[_T] | None

__slots__ = tuple(__annotations__)

def __init__(self, io_loop: IOLoop):
self._io_loop = io_loop
self._event = LateLoopEvent()
self._out: _Error | _OK[_T] | None = None
self._out = None

def __await__(self) -> Generator[object, None, _T]:
return self._result().__await__()
Expand Down
3 changes: 1 addition & 2 deletions distributed/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,11 @@ def resync(self) -> None:
thread_time = process_time


@dataclass
@dataclass(slots=True)
class MeterOutput:
start: float
stop: float
delta: float
__slots__ = tuple(__annotations__)


@contextmanager
Expand Down
6 changes: 3 additions & 3 deletions distributed/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import asyncio
import contextlib
import dataclasses
import heapq
import inspect
import itertools
Expand Down Expand Up @@ -31,6 +30,7 @@
Set,
)
from contextlib import suppress
from dataclasses import dataclass
from functools import partial
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -858,7 +858,7 @@ def occupancy(self) -> float:
)


@dataclasses.dataclass
@dataclass(slots=True)
class ErredTask:
"""Lightweight representation of an erred task without any dependency information
or runspec.
Expand All @@ -868,7 +868,7 @@ class ErredTask:
TaskState
"""

key: Hashable
key: Key
timestamp: float
erred_on: set[str]
exception_text: str
Expand Down
2 changes: 2 additions & 0 deletions distributed/worker_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ class _InstructionMatch:
cls: type[Instruction]
kwargs: dict[str, Any]

__slots__ = ("cls", "kwargs")

def __init__(self, cls: type[Instruction], **kwargs: Any):
self.cls = cls
self.kwargs = kwargs
Expand Down
Loading