ASPN ActiveState Programmer Network
  ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups | Web Services
SEARCH
advanced | search help

Reference
ActivePython 2.4
Python Documentation
Library Reference
6. Generic Operating System Services
6.1 os -- Miscellaneous operating system interfaces
6.2 os.path -- Common pathname manipulations
6.3 dircache -- Cached directory listings
6.4 stat -- Interpreting stat() results
6.5 statcache -- An optimization of os.stat()
6.6 statvfs -- Constants used with os.statvfs()
6.7 filecmp -- File and Directory Comparisons
6.8 subprocess -- Subprocess management
6.9 popen2 -- Subprocesses with accessible I/O streams
6.10 datetime -- Basic date and time types
6.11 time -- Time access and conversions
6.12 sched -- Event scheduler
6.12.1 Scheduler Objects
6.13 mutex -- Mutual exclusion support
6.14 getpass -- Portable password input
6.15 curses -- Terminal handling for character-cell displays
6.16 curses.textpad -- Text input widget for curses programs
6.17 curses.wrapper -- Terminal handler for curses programs
6.18 curses.ascii -- Utilities for ASCII characters
6.19 curses.panel -- A panel stack extension for curses.
6.20 getopt -- Parser for command line options
6.21 optparse -- More powerful command line option parser
6.22 tempfile -- Generate temporary files and directories
6.23 errno -- Standard errno system symbols
6.24 glob -- Unix style pathname pattern expansion
6.25 fnmatch -- Unix filename pattern matching
6.26 shutil -- High-level file operations
6.27 locale -- Internationalization services
6.28 gettext -- Multilingual internationalization services
6.29 logging -- Logging facility for Python
6.30 platform -- Access to underlying platform's identifying data.

MyASPN >> Reference >> ActivePython 2.4 >> Python Documentation >> Library Reference >> 6. Generic Operating System Services
ActivePython 2.4 documentation

6.12 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.

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



See About this document... for information on suggesting changes.

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState 2004 All rights reserved