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.
args = None

The arguments to pass to callback.

callback = None

The function to execute once enough time has passed.

kwargs = None

The keyword arguments to pass to callback.

name = None

The name of the task.

next = None

The time when the task should execute next.

qpointer = None

The main event queue, which allows for callbacks to be queued for execution instead of executing immediately.

repeat = None

Indicates if the task should repeat after executing, using the same seconds delay.

reset()

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

run()

Execute the task’s callback.

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

seconds = None

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)

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 = None

A queue for storing tasks

process(threaded=True, daemon=False)

Begin accepting and processing scheduled tasks.

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

Shutdown the scheduler.

remove(name)

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

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

A flag indicating that the scheduler is running.

schedule = None

A list of tasks in order of execution time.

schedule_lock = None

Lock for accessing the task queue.

stop = None

An Event instance for signalling to stop the scheduler.

thread = None

If running in threaded mode, this will be the thread processing the schedule.

wait_timeout = None

The time in seconds to wait for events from the event queue, and also the time between checks for the process stop signal.

«  XML Stream   ::   Contents   ::   XML Serialization  »

From &yet