Website hosting service by

 Back to Index

6.11 sched -- Event scheduler

The sched module defines a class which implements a general purpose event scheduler:

class scheduler( timefunc, delayfunc)
The scheduler class defines a generic interface to scheduling events. It needs two functions to actually deal with the ``outside world'' -- timefunc should be callable without arguments, and return a number (the ``time'', in any units whatsoever). The delayfunc function should be callable with one argument, compatible with the output of timefunc, and should delay that many time units. delayfunc will also be called with the argument 0 after each event is run to allow other threads an opportunity to run in multi-threaded applications.


>>> import sched, time
>>> s=sched.scheduler(time.time, time.sleep)
>>> def print_time(): print "From print_time", time.time()
>>> def print_some_times():
...     print time.time()
...     s.enter(5, 1, print_time, ())
...     s.enter(10, 1, print_time, ())
...     print time.time()
>>> print_some_times()
From print_time 930343695.274
From print_time 930343700.273



2002-2004 Webhosting Service


Disclaimer: This documentation is provided only for the benefits of our hosting customers.
For authoritative source of the documentation, please refer to


Domain registration : Buy domain name or register domain name from $5.95/year only offers cheap domain registration, domain name transfer and domain search services