| 44 | super().start(*args, **kwargs) |
| 45 | |
| 46 | def __init__(self, schedule: Optional[Schedule] = None, |
| 47 | on_error: Optional[Callable[[Exception], None]] = None, |
| 48 | on_tick: Optional[Callable[[float], None]] = None, |
| 49 | on_start: Optional[Callable[['Timer'], None]] = None, |
| 50 | max_interval: Optional[float] = None, **kwargs: Any) -> None: |
| 51 | self.schedule = schedule if schedule is not None else self.Schedule( |
| 52 | on_error=on_error, max_interval=max_interval) |
| 53 | self.on_start = on_start |
| 54 | self.on_tick = on_tick or self.on_tick |
| 55 | super().__init__() |
| 56 | # `_is_stopped` is likely to be an attribute on `Thread` objects so we |
| 57 | # double underscore these names to avoid shadowing anything and |
| 58 | # potentially getting confused by the superclass turning these into |
| 59 | # something other than an `Event` instance (e.g. a `bool`) |
| 60 | self.__is_shutdown = threading.Event() |
| 61 | self.__is_stopped = threading.Event() |
| 62 | self.mutex = threading.Lock() |
| 63 | self.not_empty = threading.Condition(self.mutex) |
| 64 | self.daemon = True |
| 65 | self.name = f'Timer-{next(self._timer_count)}' |
| 66 | |
| 67 | def _next_entry(self) -> Optional[float]: |
| 68 | with self.not_empty: |