[Twisted-Python] callLater

Manlio Perillo manlio_perillo at libero.it
Mon Sep 4 12:26:59 EDT 2006


First of all, the subject should have been "callAt" and not callLater,
sorry.

Jean-Paul Calderone ha scritto:
> On Mon, 04 Sep 2006 18:02:51 +0200, Manlio Perillo
> <manlio_perillo at libero.it> wrote:
>> Hi.
>>
>> I need to implement a function for scheduling function calls at specific
>> times.
>>
>> A simple implementation is:
>>
>> def callAt(when):
>>    from twisted.internet import reactor
>>
>>    delta = when - datetime.now()
>>    delay = delta.days * 24 * 3600 + delta.seconds + delta.microseconds
>> / 1000000.
>>
>>    return reactor.callLater(delay)
>>
>>
>> However I'm going to have lots of this scheduled calls, many of these
>> are far away in the future.
>>
>> Can this be a problem?
> 
> Profile your application and find out.  Anything else you do is premature
> optimization and a waste of time.
> 

I don't think this is a premature optimization.
I'm just considering two different implementations.

I whould like to know if someone is using thousands instances of
DelayedCall without having problems.


However only now I'm noting that the reactor uses the heapq module, so
there should be no performance problems.


Thanks and regards  Manlio Perillo




More information about the Twisted-Python mailing list