[Twisted-Python] Synchronization techniques

Bob Ippolito bob at redivi.com
Tue Apr 3 15:22:17 MDT 2007


On 4/3/07, Daniel Miller <daniel at keystonewood.com> wrote:
> Thanks for the response Itamar,
>
> >> 1. Is reactor.iterate() meant to be used this way (see
> >> TwistedLock.acquire() and TwistedProcess.check_call())? If not, what
> >> is the right way to do those things? I've read everything I can find
> >> on reactor.iterate() and while it seems to be the only way to do what
> >> I need to do, its use is often strongly discouraged. Why is it so
> >> difficult for twisted to handle non-async code?
> >
> > You should never call reactor.iterate().
>
> There really needs to be a way to do this:
>
> d = getDeferred()
> result = reactor.waitFor(d)
>
> Or even better:
>
> d = getDeferred()
> result = d.waitFor()
>
> The waitFor() method returns the result of the deferred or raises an
> exception if the deferred failed. This would allow a much more
> intuitive way to do the same type of thing that inlineCallbacks()
> allows. Why is this not implemented?

Because it's not possible.

-bob




More information about the Twisted-Python mailing list