[Twisted-Python] async code structure question

Jp Calderone exarkun at divmod.com
Thu Feb 10 16:03:28 EST 2005


On Thu, 10 Feb 2005 11:28:52 -0800, snacktime <snacktime at gmail.com> wrote:
>> >
> > > 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:)

  How?  Not with callLater, I hope.  callLater doesn't make anything 
non-blocking.

  Jp




More information about the Twisted-Python mailing list