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

Uwe C. Schroeder uwe at oss4u.com
Fri Feb 24 15:17:08 EST 2006

On Friday 24 February 2006 11:33, Gabe Rudy wrote:
> 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"

Me too actually :-)

> 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.

In the end it's not a flaw in the design. The software package with close to 
1.5 million lines of code runs just fine and did so for many years. 
The problem is that customers hire some homegrown MS Access programmers for 
whom anything remotely like network programming is a black box  and expect 
them to be able to write a module for my system. It's pretty hard to explain 
deferred's to someone who thinks a socket is the power outlet where he plugs 
his vacuum in and a port is the thing where the ships go to. Guess who gets 
the blame when their employees can't handle it. Thus the idea to make that 
API a bit less "deferred".
Yeah - I should tell them "hire decent programmers who have a clue"...
Well, was worth a try - someone might have come up with something...


Open Source Solutions 4U, LLC	1618 Kelly St
Phone:  +1 707 568 3056		Santa Rosa, CA 95401
Cell:   +1 650 302 2405		United States
Fax:    +1 707 568 6416

More information about the Twisted-Python mailing list