[Twisted-Python] Re: [Twisted-commits] r15451 - Fix test failures under windows by changing the eventual-send operation to

James Y Knight foom at fuhm.net
Sat Dec 31 12:42:07 EST 2005


On Dec 31, 2005, at 11:59 AM, James Y Knight wrote:

> On Dec 31, 2005, at 1:39 AM, Brian Warner wrote:
>
>> callLater(0) does not guarantee
>> relative ordering of sequentially-scheduled calls,
>>
>
> Yes it does: order of method call.
>
>
>> and the windows
>> reactors in fact execute them in random order.
>>
>
> That is broken.

I'm afraid this is my fault. Heapq does not guarantee stable ordering  
amongst elements with the same key, and on windows, two successive  
calls to time.time() are very likely to return the same number,  
because of its poor resolution. The same error could probably occur  
on unix/linux systems as well, although currently unlikely to the  
point of impossibility. It should be fixable by storing the last time  
of an element added to the queue, and adding epsilon if current time  
is the same.

Just as a point of interest, on my system, this loop never finishes:
import time
def f():
  while 1:
   if time.time()==time.time():
    break

But this one does:
from time import time
def f():
  while 1:
   if time()==time():
    break


James




More information about the Twisted-Python mailing list