GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • 6.10.1 Scheduler Objects

This view

  • Original page
  • New address

GeezerVison is showing docs.python.org — 6.10 sched -- Event scheduler

Previous Page Up One Level Next Page Python Library Reference Contents Module Index Index
Previous: 6.9 time Up: 6. Generic Operating System Next: 6.10.1 Scheduler Objects

6.10 sched -- Event scheduler

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

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.

Example:

>>> 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, ())
...     s.run()
...     print time.time()
...
>>> print_some_times()
930343690.257
From print_time 930343695.274
From print_time 930343700.273
930343700.276


Subsections
  • 6.10.1 Scheduler Objects


Previous Page Up One Level Next Page Python Library Reference Contents Module Index Index
Previous: 6.9 time Up: 6. Generic Operating System Next: 6.10.1 Scheduler Objects

See About this document... for information on suggesting changes.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.