Protecting against callbacks queuing up?

Esben von Buchwald find.mig at
Wed Aug 26 22:06:01 CEST 2009

Hendrik van Rooyen wrote:
>> would that be usable?
> Probably
>> If so, how?
> This is a guess, for your device,  but I suspect
> something along these lines:
> t = Ao_timer()
> cb = t.after(100,thing_that_does_the_work(with_its_arguments))
> Lots of assumptions here - the 100 should give you a tenth of a second...
> Don't know what the arguments look like, and if you need to pass an instance 
> (like self) - that would depend on where you are calling it from.
> Play and see :-)
> You should also be able to cancel the callback like this:
> t.cancel(cb)
> If you do it before the time out
> - Hendrik

I don't really get it...

I can see that I should put a t.after(...) around the function that does 
the work, when calling it. That delays each call for the given period. I 
just tried it out, the console keeps saying
Traceback (most recent call last):
   File "c:\resource\python25\\", line 499, in 
   File "c:\resource\python25\\", line 160, in 
   File "e:\python\", line 79, in acc_filter
   File "e:\python\", line 85, in acc_callback
   File "e:\python\", line 47, in doCallback,self.data_callback)
RuntimeError: Timer pending - cancel first


It seems like i should cancel the current counting timer, when a new 
call comes in - but how to determine when to cancel etc?

I'm kind of new to all this async python stuff.

More information about the Python-list mailing list