On Thu, 15 May 2008 18:48:22 -0500
[EMAIL PROTECTED] wrote:
> I believe it works like this:
>
> set wakeup for X milliseconds from now
> call your callback
> if it returned true:
> set wakeup for X milliseconds from now
> call your callback
> if it returned true:
> set wakeup for X milliseconds from now
> call your callback
> if it returned true:
> set wakeup for X milliseconds from now
> ...
>
> If X is 2500ms and your callback takes 2ms to execute, the interval between
> successive calls will actually be 2502ms.
Unfortunately, it is how it work. In fact, that how I would like it to
work. Here is what my testing shows:
t0: set wakeup for X milliseconds from now
t0+X: set wakeup for X milliseconds from now (t0+X+X)
call callback
if it returned true: noop
else: delete the timer
Here is an example:
#!/usr/bin/python
import gtk
import gobject
import time
def callback (timeout):
print "callback called at: %s"%time.time ()
time.sleep (timeout)
print "callback returning at: %s"%time.time ()
return True
if __name__ == "__main__":
gobject.timeout_add (20*1000, callback, 10)
gtk.main ()
If you run this, you get:
callback called at: 1210897497.69
callback returning at: 1210897507.69
callback called at: 1210897517.69
callback returning at: 1210897527.69
callback called at: 1210897537.69
callback returning at: 1210897547.69
callback called at: 1210897557.69
Note that the time difference between the "callback returning at" and
"callback called at" is not 20 seconds but 10 seconds (20 second timeout
- 10 second callback runtime).
--
Mitko Haralanov
==========================================
A programming language is low level when its programs require attention
to the irrelevant.
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/