Website hosting service by

 Back to Index

7.5.7 Timer Objects

This class represents an action that should be run only after a certain amount of time has passed -- a timer. Timer is a subclass of Thread and as such also functions as an example of creating custom threads.

Timers are started, as with threads, by calling their start() method. The timer can be stopped (before its action has begun) by calling the cancel() method. The interval the timer will wait before executing its action may not be exactly the same as the interval specified by the user.

For example:

def hello():
    print "hello, world"

t = Timer(30.0, hello)
t.start() # after 30 seconds, "hello, world" will be printed
class Timer( interval, function, args=[], kwargs={})
Create a timer that will run function with arguments args and keyword arguments kwargs, after interval seconds have passed.
cancel( )
Stop the timer, and cancel the execution of the timer's action. This will only work if the timer is still in its waiting stage.




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


Cheap domain registration : Register domain name or buy domain name, including free domain hosting services offers cheap domain registration, domain name transfer and domain search services    

Domain registration : Buy domain name or register domain name from $5.95/year only