Patches item #1676820, was opened at 2007-03-08 22:28 Message generated for change (Comment added) made by sonderblade You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1676820&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Library (Lib) Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Bj�rn Lindqvist (sonderblade) Assigned to: Nobody/Anonymous (nobody) Summary: Add a PeriodicTimer to threading Initial Comment: I have often wanted a timer in Python with the same functions as Javas Timer (http://java.sun.com/javase/6/docs/api/java/util/Timer.html). I want it repeating instead of being just a one-shot thing like Pythons Timer class. Here is a patch that adds such a class to the threading module. You then use it like this: import threading def hello(): print "Hi there!" t = threading.PeriodicTimer(5, hello) t.start() # "Hi there!" will be printed every five seconds. The use cases for this class is things like updating canvases, updating simulations and polling stuff. I can provide documentation and unit test patches if this class is deemed worthy. ---------------------------------------------------------------------- >Comment By: Bj�rn Lindqvist (sonderblade) Date: 2007-03-09 20:40 Message: Logged In: YES user_id=51702 Originator: YES I choose the name to match the Timer class and the java.util.Timer class in the Java API. I'll rename it to "end" so that the caller gets the hint that further invocations of "start" is meaningless. ---------------------------------------------------------------------- Comment By: Martin v. Löwis (loewis) Date: 2007-03-09 08:15 Message: Logged In: YES user_id=21627 Originator: NO Looks fine to me. The only issue I see is naming: To stop a periodic timer, shouldn't the method name be "stop" rather than "cancel"? Also, as you can hold onto the timer, make sure invoking start/'end' multiple times in arbitrary order gives meaningful results. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1676820&group_id=5470
_______________________________________________ Patches mailing list Patches@python.org http://mail.python.org/mailman/listinfo/patches