Timer

Timer Event

class detroit_live.timer.timer.TimerEvent
is_set() bool
set()
clear()

Timer

async detroit_live.timer(callback: Callable[[float, TimerEvent], None], delay: float | None = None, starting_time: float | None = None) Timer

Schedules a new timer, invoking the specified callback repeatedly until the timer is stopped. An optional numeric delay in milliseconds may be specified to invoke the given callback after a delay; if delay is not specified, it defaults to zero. The delay is relative to the specified starting_time in milliseconds; if starting_time is not specified, it defaults to now.

Parameters:
  • callback (Callable[[float, TimerEvent], None]) – Callback

  • delay (float | None) – Delay value

  • starting_time (float | None) – Starting time value

Returns:

Timer

Return type:

Timer

class detroit_live.timer.timer.Timer
async restart(callback: Callable[[float, TimerEvent], None], delay: float | None = None, starting_time: float | None = None) int
stop()

Interval

async detroit_live.interval(callback: Callable[[float, TimerEvent], None], delay: float | None = None, starting_time: float | None = None) Timer | Interval

The callback is invoked only every delay milliseconds; if delay is not specified, this is equivalent to timer.

Parameters:
  • callback (Callable[[float, TimerEvent], None]) – Callback

  • delay (float | None) – Delay value

  • starting_time (float | None) – Starting time value

Returns:

Timer if delay is not specified else Interval.

Return type:

Timer | Interval

class detroit_live.timer.interval.Interval
async restart(callback: Callable[[float, TimerEvent], None], delay: float | None = None, starting_time: float | None = None) int
stop()

Timeout

async detroit_live.timeout(callback: Callable[[float, TimerEvent], None], delay: float | None = None, starting_time: float | None = None) Timer

Automatically stops on its first callback.

Parameters:
  • callback (Callable[[float, TimerEvent], None]) – Callback

  • delay (float | None) – Delay value

  • starting_time (float | None) – Starting time value

Returns:

Timer with timeout

Return type:

Timer