Timed events documentation

Timed events are the standard way to schedule events for later in poezio.

Once created, they must be added to the list of checked events with Core.add_timed_event() (within poezio) or with PluginAPI.add_timed_event() (within a plugin).

class timed_events.TimedEvent(date, callback, *args)[source]

An event with a callback that is called when the specified time is passed.

Note that these events can NOT be used for very small delay or a very precise date, since the check for events is done once per second, as a maximum.

The callback and its arguments should be passed as the lasts arguments.

__init__(date, callback, *args)[source]

Create a new timed event.

Parameters:
  • date (datetime.datetime) -- Time at which the callback must be run.

  • callback (function) -- The handler that will be executed.

  • *args -- Optional arguments passed to the handler.

has_timed_out(current_date)[source]

Check if the event has timed out.

Parameters:

current_date (datetime.datetime) -- The current date.

Returns:

True if the callback should be called

Return type:

bool

change_date(date)[source]

Simply change the date of the event.

Parameters:

date (datetime.datetime) -- Next date.

add_delay(delay)[source]

Add a delay (in seconds) to the date.

Parameters:

delay (int) -- The delay to add.

class timed_events.DelayedEvent(delay, callback, *args)[source]

A TimedEvent, but with the date calculated from now + a delay in seconds. Use it if you want an event to happen in, e.g. 6 seconds.

__init__(delay, callback, *args)[source]

Create a new DelayedEvent.

Parameters:
  • delay (int) -- The number of seconds.

  • callback (function) -- The handler that will be executed.

  • *args -- Optional arguments passed to the handler.