Scheduler¶
- class sleekxmpp.xmlstream.scheduler.Task(name, seconds, callback, args=None, kwargs=None, repeat=False, qpointer=None)[source]¶
A scheduled task that will be executed by the scheduler after a given time interval has passed.
- Parameters:
name (string) – The name of the task.
seconds (int) – The number of seconds to wait before executing.
callback – The function to execute.
args (tuple) – The arguments to pass to the callback.
kwargs (dict) – The keyword arguments to pass to the callback.
repeat (bool) – Indicates if the task should repeat. Defaults to
False
.pointer – A pointer to an event queue for queuing callback execution instead of executing immediately.
- callback¶
The function to execute once enough time has passed.
- name¶
The name of the task.
- next¶
The time when the task should execute next.
- qpointer¶
The main event queue, which allows for callbacks to be queued for execution instead of executing immediately.
- run()[source]¶
Execute the task’s callback.
If an event queue was supplied, place the callback in the queue; otherwise, execute the callback immediately.
- seconds¶
The number of seconds to wait before executing.
- class sleekxmpp.xmlstream.scheduler.Scheduler(parentstop=None)[source]¶
A threaded scheduler that allows for updates mid-execution unlike the scheduler in the standard library.
Based on: http://docs.python.org/library/sched.html#module-sched
- Parameters:
parentstop – An
Event
to signal stopping the scheduler.
- add(name, seconds, callback, args=None, kwargs=None, repeat=False, qpointer=None)[source]¶
Schedule a new task.
- Parameters:
name (string) – The name of the task.
seconds (int) – The number of seconds to wait before executing.
callback – The function to execute.
args (tuple) – The arguments to pass to the callback.
kwargs (dict) – The keyword arguments to pass to the callback.
repeat (bool) – Indicates if the task should repeat. Defaults to
False
.pointer – A pointer to an event queue for queuing callback execution instead of executing immediately.
- addq¶
A queue for storing tasks
- process(threaded=True, daemon=False)[source]¶
Begin accepting and processing scheduled tasks.
- Parameters:
threaded (bool) – Indicates if the scheduler should execute in its own thread. Defaults to
True
.
- remove(name)[source]¶
Remove a scheduled task ahead of schedule, and without executing it.
- Parameters:
name (string) – The name of the task to remove.
- run¶
A flag indicating that the scheduler is running.
- schedule¶
A list of tasks in order of execution time.
- schedule_lock¶
Lock for accessing the task queue.
- thread¶
If running in threaded mode, this will be the thread processing the schedule.
- wait_timeout¶
The time in seconds to wait for events from the event queue, and also the time between checks for the process stop signal.