Skip to content

mode.types.supervisors

Type classes for mode.supervisors.

SupervisorStrategyT

Bases: ServiceT

Base type for all supervisor strategies.

Source code in mode/types/supervisors.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class SupervisorStrategyT(ServiceT):
    """Base type for all supervisor strategies."""

    max_restarts: float
    over: float
    raises: Type[BaseException]

    @abc.abstractmethod
    def __init__(
        self,
        *services: ServiceT,
        max_restarts: Seconds = 100.0,
        over: Seconds = 1.0,
        raises: Optional[Type[BaseException]] = None,
        replacement: ReplacementT = None,
        **kwargs: Any,
    ) -> None:
        self.replacement: Optional[ReplacementT] = replacement

    @abc.abstractmethod
    def wakeup(self) -> None: ...

    @abc.abstractmethod
    def add(self, *services: ServiceT) -> None: ...

    @abc.abstractmethod
    def discard(self, *services: ServiceT) -> None: ...

    @abc.abstractmethod
    def service_operational(self, service: ServiceT) -> bool: ...

    @abc.abstractmethod
    async def restart_service(self, service: ServiceT) -> None: ...