remotivelabs.topology.time.callback
1from __future__ import annotations 2 3from typing import Protocol 4 5 6class OnTickCallback(Protocol): 7 """ 8 Callback function that will be called on each tick. 9 """ 10 11 async def __call__(self, elapsed_time: float, since_last_tick: float, total_drift: float, interval: float) -> bool | None: 12 """ 13 Args: 14 elapsed_time: The time since the start of the ticker, in seconds 15 since_last_tick: The time since the last tick, in seconds 16 total_drift: The total drift time, in seconds 17 interval: The desired interval between ticks, in seconds 18 19 Returns: 20 True if the ticker should stop, False or None otherwise 21 """
class
OnTickCallback(typing.Protocol):
7class OnTickCallback(Protocol): 8 """ 9 Callback function that will be called on each tick. 10 """ 11 12 async def __call__(self, elapsed_time: float, since_last_tick: float, total_drift: float, interval: float) -> bool | None: 13 """ 14 Args: 15 elapsed_time: The time since the start of the ticker, in seconds 16 since_last_tick: The time since the last tick, in seconds 17 total_drift: The total drift time, in seconds 18 interval: The desired interval between ticks, in seconds 19 20 Returns: 21 True if the ticker should stop, False or None otherwise 22 """
Callback function that will be called on each tick.
OnTickCallback(*args, **kwargs)
1945def _no_init_or_replace_init(self, *args, **kwargs): 1946 cls = type(self) 1947 1948 if cls._is_protocol: 1949 raise TypeError('Protocols cannot be instantiated') 1950 1951 # Already using a custom `__init__`. No need to calculate correct 1952 # `__init__` to call. This can lead to RecursionError. See bpo-45121. 1953 if cls.__init__ is not _no_init_or_replace_init: 1954 return 1955 1956 # Initially, `__init__` of a protocol subclass is set to `_no_init_or_replace_init`. 1957 # The first instantiation of the subclass will call `_no_init_or_replace_init` which 1958 # searches for a proper new `__init__` in the MRO. The new `__init__` 1959 # replaces the subclass' old `__init__` (ie `_no_init_or_replace_init`). Subsequent 1960 # instantiation of the protocol subclass will thus use the new 1961 # `__init__` and no longer call `_no_init_or_replace_init`. 1962 for base in cls.__mro__: 1963 init = base.__dict__.get('__init__', _no_init_or_replace_init) 1964 if init is not _no_init_or_replace_init: 1965 cls.__init__ = init 1966 break 1967 else: 1968 # should not happen 1969 cls.__init__ = object.__init__ 1970 1971 cls.__init__(self, *args, **kwargs)