Scheduler

1.0 Documentation

«  XML Stream   ::   Contents   ::   XML Serialization  »

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.
reset()[source]

Reset the task’s timer so that it will repeat.

run()[source]

Execute the task’s callback.

If an event queue was supplied, place the callback in the queue; otherwise, execute the callback immediately.

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.
process(threaded=True)[source]

Begin accepting and processing scheduled tasks.

Parameters:threaded (bool) – Indicates if the scheduler should execute in its own thread. Defaults to True.
quit()[source]

Shutdown the scheduler.

remove(name)[source]

Remove a scheduled task ahead of schedule, and without executing it.

Parameters:name (string) – The name of the task to remove.

«  XML Stream   ::   Contents   ::   XML Serialization  »

From &yet