Skip to content

Timer

Timer objects are created by set_interval or set_timer.

Timer

A class to send timer-based events.

Parameters:

Name Type Description Default
event_target MessageTarget

The object which will receive the timer events.

required
interval float

The time between timer events.

required
sender MessageTarget

The sender of the event.

required
name str | None

A name to assign the event (for debugging). Defaults to None.

None
callback TimerCallback | None

A optional callback to invoke when the event is handled. Defaults to None.

None
repeat int | None

The number of times to repeat the timer, or None to repeat forever. Defaults to None.

None
skip bool

Enable skipping of scheduled events that couldn't be sent in time. Defaults to True.

True
pause bool

Start the timer paused. Defaults to False.

False

pause()

Pause the timer.

A paused timer will not send events until it is resumed.

reset()

Reset the timer, so it starts from the beginning.

resume()

Resume a paused timer.

start()

Start the timer return the task.

Returns:

Name Type Description
Task Task

A Task instance for the timer.

stop() async

Stop the timer, and block until it exits.

stop_no_wait()

Stop the timer.