[Twisted-Python] callLater

Drew Smathers drew.smathers at gmail.com
Thu Jan 17 17:11:22 EST 2008


On Jan 17, 2008 4:54 PM, Eduardo Matus <ematus at gmail.com> wrote:

> hey.. the code is to.... dirty.. but look this...
>
> reactor.callLater(3,f)
>
> for x in range(100000000000000): # for example... a big time-consumption
>        #do something
> reactor.callLater(3,g)
>
> the 'g' method will not start at the same time of 'f'
>


You would want to schedule your calls before doing CPU-intensive work.  And
you don't want to do CPU-intensive work in the same thread as the reactor
anyways because this is equivalent to blocking.  Consider putting whatever
takes a lot of time in a separate process or a in a thread pool via
deferToThread.

-- 
\\\\\/\"/\\\\\\\\\\\
\\\\/ // //\/\\\\\\\
\\\/  \\// /\ \/\\\\
\\/ /\/ / /\/ /\ \\\
\/ / /\/ /\  /\\\ \\
/ /\\\  /\\\ \\\\\/\
\/\\\\\/\\\\\/\\\\\\
              d.p.s
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20080117/f0501791/attachment.htm 


More information about the Twisted-Python mailing list