On Oct 19, 4:01 am, sokol <[EMAIL PROTECTED]> wrote: > > > I started googling for scheduler and found one in standard library > > > but ih has the same code as mine (it calls the functions in the > > > right order and my doesn't, but it still waits too long). > > > The other schedulers from web are dealing with > > > repeating tasks and such. > > > I believe you're looking for the 'sched' > > module:http://www.python.org/doc/2.5.2/lib/module-sched.html > > The sched module behaves just like mine version because > it uses almost the same code. My observations include the > sched module as well. Check it's source code. It is flawed: > it calls the sleep method and while it sleeps (presumably > for a long time) all newly scheduled events are on hold. > See my example in original post. > > My code solves this problem (or so it looks to me right now).
The trick to your problem is the heart of any event-driven programming: Event Queue. There will always be a mainloop, which is a method that would check the queue for new events and execute the appropriate callbacks for each event. For a Timer object, it will be an event that returns a callback that simply reinserts itself to the the queue until "the time" has arrived. When the time has arrived, it will execute the function you've given before. Note that there is no need to use threading here. -- http://mail.python.org/mailman/listinfo/python-list