Protecting against callbacks queuing up?

Esben von Buchwald find.mig at paa.google
Thu Aug 27 18:31:15 EDT 2009


Dennis Lee Bieber wrote:
> 
> 	The only other thing I could suggest is exactly what is done on:
> http://pys60.garage.maemo.org/doc/s60/node59.html
> 
> 	Initialize a counter value to 0, then increment it in the callback,
> only doing REAL work every n calls.
> 
> 
> 	def doCallback(self):
> 		if self.count % 35 == 0:	#doc says 35 hits/second, so this
> 			self.data_callback()	#will run one once per second
> 		self.count += 1
> 
> 	You'll still get that slew of backlogged callbacks that built up
> while doing the real processing, but unless self.data_callback() takes
> more time than the "35" covers, most of the callbacks will just come in
> and exit with an increment.

Of course I can do that.


But it'll only make a noticable delay EVERY time the user moves, and not 
prevent the build up of calls if it doesn't finish within the 35 callbacks.

The point is that I don't know in advance, how long the call will take. 
It depends on the amount of data i load and process during the call.
I only know when the calculations have finished, and when they are 
called, and think there might be some way to block further callbacks 
until the first one returns?



More information about the Python-list mailing list