[Twisted-Python] How to force synchronous behavior

Jean-Paul Calderone exarkun at divmod.com
Sat Oct 29 12:50:07 EDT 2005

On Sat, 29 Oct 2005 18:02:25 +0200, Marcin Kasperski <marcin.kasperski at softax.com.pl> wrote:
>>>I want to encapsulate deferreds into a function that looks like
>>>synchronous when invoked.
>>This is a bad idea.  Don't do it.
>Depends on the purpose...
>There is deferredResult function somewhere in trial (twisted testing) 
>package,  deferredResult(somedeferred)  just waits  for this deferred - 
>yielding control to the reactor  repeatably. This is probably what original 
>poster looks for.

Because there seems to be so much confusion on this point,
let me re-iterate Itamar's response:

deferredResult is *broken*.  It does not work now.  It never
worked in the past.  If you use it, your program will suck and
die and you will be sad and the only advise you will get
to fix it will be to stop using deferredResult, which will
probably mean rewriting a significant portion of your program,
since you cannot write asynchronous programs synchronously and
expect them to work.

This is not a conditional point.  It does not depend on
anything.  It is a simple, unavoidable fact.  Disregard it at
your own certain peril.


More information about the Twisted-Python mailing list