evennia.scripts.taskhandler¶
Module containing the task handler for Evennia deferred tasks, persistent or not.
-
class
evennia.scripts.taskhandler.
TaskHandler
[source]¶ Bases:
object
A light singleton wrapper allowing to access permanent tasks.
When utils.delay is called, the task handler is used to create the task. If utils.delay is called with persistent=True, the task handler stores the new task and saves.
It’s easier to access these tasks (should it be necessary) using evennia.scripts.taskhandler.TASK_HANDLER, which contains one instance of this class, and use its add and remove methods.
-
load
()[source]¶ Load from the ServerConfig.
Note
This should be automatically called when Evennia starts. It populates self.tasks according to the ServerConfig.
-
add
(timedelay, callback, *args, **kwargs)[source]¶ Add a new persistent task in the configuration.
- Parameters
timedelay (int or float) – time in sedconds before calling the callback.
callback (function or instance method) – the callback itself
any (any) – any additional positional arguments to send to the callback
- Keyword Arguments
persistent (bool, optional) – persist the task (store it).
any (any) – additional keyword arguments to send to the callback
-
remove
(task_id)[source]¶ Remove a persistent task without executing it.
- Parameters
task_id (int) – an existing task ID.
Note
A non-persistent task doesn’t have a task_id, it is not stored in the TaskHandler.
-