[Twisted-Python] callLater(0) is A BIG LIE

Phillip J. Eby pje at telecommunity.com
Mon Nov 1 13:27:16 EST 2004

At 12:51 PM 11/1/04 -0500, Bob Ippolito wrote:
>Actually callLater(0, ....) was an edge case up until recently (I hope it 
>got fixed?) where it DID run in the current iteration.. a timer that fired 
>another timer with 0 delay would cause the timer processing to never 
>finish, so IO wouldn't happen anymore.
>Of course, everyone expected it to mean "call function f in the next 
>reactor iteration".. but it didn't :)

Right; I'm arguing that even in a "sane" scheduler it *doesn't* mean that, 
on a sufficiently fast machine with a sufficiently low-granularity 
clock.  For example, on Windows, time.time() has sufficiently low 
resolution that this can happen.

However, regardless of clock resolution, using a *non-zero* value for 
callLater, regardless of how small the value is, is sufficient to ensure 
that the item is run in the next iteration.  This should be true for any 
sane scheduler (i.e., one that can't enter a state of perpetual I/O 

More information about the Twisted-Python mailing list