Issue428326
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2001-05-29 15:20 by itamar, last changed 2022-04-10 16:04 by admin. This issue is now closed.
Files | ||||
---|---|---|---|---|
File name | Uploaded | Description | Edit | |
timer.py | itamar, 2001-05-29 15:20 | Timer class | ||
/usr/src/python-cvs/doc.patch | itamar, 2001-09-04 14:49 | Documentation patch |
Messages (12) | |||
---|---|---|---|
msg36669 - (view) | Author: Itamar Shtull-Trauring (itamar) | Date: 2001-05-29 15:20 | |
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. |
|||
msg36670 - (view) | Author: Itamar Shtull-Trauring (itamar) | Date: 2001-05-29 16:45 | |
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. |
|||
msg36671 - (view) | Author: Itamar Shtull-Trauring (itamar) | Date: 2001-05-30 09:16 | |
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 |
|||
msg36672 - (view) | Author: Itamar Shtull-Trauring (itamar) | Date: 2001-05-30 16:40 | |
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. |
|||
msg36673 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2001-08-08 20:32 | |
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. |
|||
msg36674 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2001-08-08 20:53 | |
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 :-( ). |
|||
msg36675 - (view) | Author: Itamar Shtull-Trauring (itamar) | Date: 2001-08-09 21:23 | |
Logged In: YES user_id=32065 1) license can be python's and copyright PSF's 2) I will write docs and tests 3) not sure when, maybe this weekend One question - timers actually seem to be a task that happens repeatedly every X seconds (e.g. in wxWindows). Should I add that functionality (do a task every X seconds, N times, N is either >= 1 or infinite) or just rename the class? |
|||
msg36676 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2001-08-09 21:45 | |
Logged In: YES user_id=6380 Good! I don't think there's a standard definition of timers -- I've seen both. A more general timer that can go off N times, defaulting to once, sounds like a nice API. Hm, I can actually only think of two usage scenarios: either you want it to go off once, or you want it to repeat until you cancel it. Think about it. There's also the msg from Aahz in the python-dev list where he claims he doesn't like something about this without saying what. I hope he clarifies that in this SF tracker item. |
|||
msg36677 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2001-08-10 08:21 | |
Logged In: YES user_id=21627 A quick poll among colleagues shows that shoot-once timers are far more common than repeated intervall timers. You also can quite easily implement the intervall timer on top of a shoot-once timer, by restarting it in the timeout handler (although care is needed if you need exact intervalls: between last scheduled time-out and the handler invocation, time may pass, so the restart may need to be smaller than the intervall). In short, I think the API as you provide it is excellent; if people find it useful and require more, they will provide patches. |
|||
msg36678 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2001-08-10 13:51 | |
Logged In: YES user_id=6380 OK. Let's do a one-short timer only. |
|||
msg36679 - (view) | Author: Itamar Shtull-Trauring (itamar) | Date: 2001-09-04 14:49 | |
Logged In: YES user_id=32065 I've attached a patch to the documentation. I don't know LaTex so there may be some errors (although the HTML output seems OK). |
|||
msg36680 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2001-09-05 13:46 | |
Logged In: YES user_id=21627 Thanks for the patch; it is committed as threading.py 1.18, libthreading.tex 1.11, NEWS 1.230. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:04:05 | admin | set | github: 34555 |
2001-05-29 15:20:29 | itamar | create |