[Twisted-Python] scheduling timers with long interval

Jean-Paul Calderone exarkun at divmod.com
Fri Aug 17 22:54:12 EDT 2007


On Fri, 17 Aug 2007 16:25:19 -0700 (PDT), Alec Matusis <matusis at yahoo.com> wrote:
>I have a server that is running for weeks without restart, under significant load.
>I am considering adding a function to it that requires setting long timers like
>
>twisted.internet.reactor.callLater(604800, func)
>
>i.e. scheduling events one week ahead. There will be up to 500 timers active at any given time.
>
>I do not know how the scheduler works. Will having these timers with very long intervals significantly tax the performance, since the reactor will have to check on their status with every churn of the reactor loop?

There is a minor memory cost associated with each task.  Beyond that, there
is a roughly log(N) insertion cost for new DelayedCalls, where N is the
number of existing outstanding calls.  The scheduling itself is basically
constant time.  None of the reactors should even notice if you have just
500 outstanding DelayedCalls.

Jean-Paul




More information about the Twisted-Python mailing list