Protecting against callbacks queuing up?

Esben von Buchwald find.mig at paa.google
Mon Aug 24 02:14:24 CEST 2009


Hello

I'm using Python for S60 1.9.7 on my Nokia phone.

I've made a program that gets input from an accelerometer sensor, and 
then calculates some stuff and displays the result.

The sensor framework API does a callback to a function defined by me, 
every time new data is available.

The problem is, that sometimes, the calculations may take longer than 
others, but if the callback is called before the first calculation is 
done, it seems like it's queuing up all the callbacks, and execute them 
sequentially, afterwards.

What I need, is to simply ignore the callback, if the previous call 
hasn't finished it's operations before it's called again.

I thought that this code would do the trick, but it obviously doesn't 
help at all, and i can't understand why...

     def doCallback(self):
         if self.process_busy==False:
             self.process_busy=True
             self.data_callback()
             self.process_busy=False


doCallback is defined as a callback function for the accelerometer 
instance, and data_callback does some calculations and show them on the 
display of the phone.

What to do? Thanks...



More information about the Python-list mailing list