[Patches] [ python-Patches-428326 ] Timer class for threading
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 29 May 2001 09:45:53 -0700
Patches item #428326, was updated on 2001-05-29 08:20
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=428326&group_id=5470
Category: library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Itamar Shtull-Trauring (itamar)
Assigned to: Nobody/Anonymous (nobody)
Summary: Timer class for threading
Initial Comment:
The Timer class allows you to schedule an action to
happen at some time in the future, using a thread. For
example:
def f():
print "30 seconds have passed"
t = Timer(30.0, f)
t.start() # after 30 seconds f will be called
try:
# .... other stuff
except SystemExit:
t.cancel() # cancel the timer since we are
shutting down
It allows passing arguments and keyword arguments to
the function that is called. It also allows
*cancelling* the timer. That is, if the timer is still
waiting, we can tell it to stop its operation.
Why should this be in the standard library?
1. Timers are a standard, useful programming idiom.
2. It can be used as an example of how to:
a. create subclasses of threading.Thread
b. make threads that can be "stopped"
If this patch is approved I will then write
documentation. I'm not sure how to go about writing
tests for it.
----------------------------------------------------------------------
>Comment By: Itamar Shtull-Trauring (itamar)
Date: 2001-05-29 09:45
Message:
Logged In: YES
user_id=32065
I'm withdrawing this patch for a short period of time for
non-technical reasons, hopefully I can put it back soon.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=428326&group_id=5470