[Twisted-Python] async code structure question

snacktime snacktime at gmail.com
Thu Feb 10 14:28:52 EST 2005


> >
> > def Do():
> >     d = deferToThread(foo)
> >     d.addCallback(processResult)
> >     return d
> >
> > or
> >
> > def Do():
> >     # processing in this case is waiting for one second
> >     d = Deferred()
> >     reactor.callLater(d.callback, 1)
> 
>    reactor.callLater(1, d.callback, "foo")
> 
>  But this is much less realistic than the first example :)

The first example is what I was doing and it worked just fine.  But
now I've rewritten everything so it's non blocking and I no longer
need to use deferToThread.  I found out that it's a bit more
complicated now though:)




More information about the Twisted-Python mailing list