[Twisted-Python] Writing a wrapper from asynchronous to synchronous

Gabe Rudy rudy at goldenhelix.com
Fri Feb 24 14:33:33 EST 2006

On Thursday 23 February 2006 11:46 pm, Uwe C. Schroeder wrote:
> Hi everyone,
> I know someone is going to say it's a flaw in the design - and I partially
> agree with that. However I have an application that allows a fairly
> unexperienced programmer to add modules. What I need to do is to write a
> wrapper that hides the asynchronous nature of pb 

Lol, when I read that I wondered how long it will it take before someone _did_ 
respond with "It's a flaw in the design"

I actually was trying to do this _exact_ thing (making pb appear synchronous) 
and met with similar remarks to my post for help. But even though I did 
manage to write a hack using a interleaved threadedselectreactor, 
threading.Event and a forced event processing while loop, the result was 
mostly functional but ugly and a pain to debug.

It was a flaw in my design.

And after some serious reworking and acceptance of a more asynchronous 
methodology, my program is the better for it. Way better.

In short, I would recommend _not_ forcing/hacking twisted to be something its 
not. Use L. Daniel's suggestion, use a synchronous network system like 
xmlrpclib, or rethink the meta problem your are trying to solve.


More information about the Twisted-Python mailing list