[Twisted-Python] callLater

Christopher Armstrong radix at twistedmatrix.com
Thu Jan 17 17:07:35 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'

Twisted is an asynchronous framework. Your code needs to not block for
long times in order for it to function properly, so don't block for a
long time in 'f' and everything will be fine.

If you really need to run some blocking function, maybe you want to
use a thread, in which case something like
twisted.internet.threads.deferToThread is desirable.

Christopher Armstrong
International Man of Twistery

More information about the Twisted-Python mailing list