[Twisted-Python] Scalability of timers

Tobias Oberstein tobias.oberstein at tavendo.de
Sun Aug 10 17:51:40 MDT 2014


>>I want to trade less precision (timers fire at less exact times) for higher efficiency (less context switches). 

>It's easy enough to write one yourself. This might work:
>from twisted.internet.task import Clock, LoopingCall
>
>clock = Clock()
>LoopingCall(lambda: clock.advance(0.001)).start(0.001)
>Now just do "clock.callLater" instead of "reactor.callLater".

Oh, cool. That make me smile;)

Does what I want, is simple and portable. Great.

Only worry is

http://twistedmatrix.com/trac/browser/tags/releases/twisted-14.0.0/twisted/internet/task.py#L767

Why does it sort after each and every callLater?

And:
http://twistedmatrix.com/trac/browser/tags/releases/twisted-14.0.0/twisted/internet/task.py#L793

It also sorts after each firing of a delayed call. Presumably because that delayed call might reschedule another call that might also fire in same time period?

/Tobias




More information about the Twisted-Python mailing list