[Patches] [ python-Patches-428326 ] Timer class for threading

noreply@sourceforge.net noreply@sourceforge.net
Wed, 08 Aug 2001 13:53:59 -0700


Patches item #428326, was opened at 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: Guido van Rossum (gvanrossum)
Date: 2001-08-08 13:53

Message:
Logged In: YES 
user_id=6380

I like it too.

But I don't want itamar's license anywhere in the
distribution -- too wordy.

I agree that the PSF should clear up the licensing
situation; we're working
on that but it's slow going (nobody likes this work :-( ).


----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2001-08-08 13:32

Message:
Logged In: YES 
user_id=21627

I'm in favour of approving this patch, as an extension to 
the threading module. Are you willing to draft a patch to 
the documentation (libthreading.tex) as well?

Ideally, there would also be a set of regression tests in 
a test_threading file; it would be acceptable if this only 
tests your feature for the moment.


----------------------------------------------------------------------

Comment By: Itamar Shtull-Trauring (itamar)
Date: 2001-05-30 09:40

Message:
Logged In: YES 
user_id=32065

There was a licensing discussion on python-dev which no one
bothered to CC me on :). Yes, this can be relicensed under
the PSF license. 

I suggest someone write up some sort of guidelines for
submitted patches and improvement explain the whole
licensing and copyright issues.

----------------------------------------------------------------------

Comment By: Itamar Shtull-Trauring (itamar)
Date: 2001-05-30 02:16

Message:
Logged In: YES 
user_id=32065

OK, I'm un-withdrawing this patch.  Just had to get things
straight with our lawyer. The patch is released under the
following license (the X11 license with 4 extra paragraphs
of disclaimers :):
http://www.zoteca.com/opensource/LICENSE.txt

----------------------------------------------------------------------

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