[Twisted-Python] patch for background processing (delay 0)

Bob Ippolito bob at redivi.com
Wed May 19 01:10:58 EDT 2004


In my heapq implementation of a similar timer mechanism (outside of 
Twisted), I did three things that twisted doesn't:
- cancelling a timer doesn't try and remove it from the heapq, instead 
it just marks the timer as dead.
- the time when it's supposed to fire is passed to the fire method so 
that the timer can determine whether it's supposed to actually fire or 
not (in the case of a time change it is actually added to the queue a 
second time without being removed so that I don't have to disrupt the 
heapq).
- it's two phase.. I have a list of newly added timers, and a heapq of 
waiting-to-fire timers.  At the end of the iteration I shove the list 
into the heapq and clear the list.  This prevents infinite callLater(0, 
...) situations.

-bob

On May 19, 2004, at 12:53 AM, Bill la Forge wrote:

>
> You're quite welcome. I just hope it passes the regression tests!
>  
> I did manage, finally, to download cygwin. (Been a few years since I've
>  used it.) Here in India, bandwidth depends on a lot more than the 
> dialup
>  connection. ;-) (Though things have improved greatly in the last few
>  years.)
>  
> As for speed, I still suspect that heapq may be faster than insort. I 
> know
>  there's a few places in the code base where the last element is
>  inspected (timeout method comes to mind) that would need to be
>  changed to the first element.
>   
> And, of course, Heapq is mising the remove method (I've since coded 
> it).
>  
> But then there's the resetter method... might be impacted and I can't
>  figure it out. ;-(
>  
> Bill
>
> Jp Calderone <exarkun at divmod.com> wrote:
> Thanks for the contribution :) By the way, for a slightly less hefty
>  download than cygwin, check out http://unxutils.sourceforge.net/ 
> (kindly
>  pointed out by bear in #twisted). It includes a Windows-native diff 
> tool.
>
> Jp
>
>
> Bill la Forge
> http://www.geocities.com/laforge49/
>
> Yahoo! India Matrimony: Find your partner  online.
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2357 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20040519/48f4342f/attachment.bin 


More information about the Twisted-Python mailing list