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

glyph at divmod.com glyph at divmod.com
Fri Feb 24 11:53:17 EST 2006



On Thu, 23 Feb 2006 22:46:03 -0800, "Uwe C. Schroeder" <uwe at oss4u.com> wrote:
>
>Hi everyone,
>
>I know someone is going to say it's a flaw in the design 

I would hate to disappoint you.

"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 

No, you don't.  What you need to do is to edcucate your target developer market about asynchronous programming.  It's not that hard.  The TurboGears "20 minute wiki" tutorial even covers Deferreds, without really bothering to explain how they work.  If average JavaScript monkeys can figure this out, I think you're not giving your target developers enough credit.

You cannot "hide the asynchronous nature of PB".  The protocol is fully asynchronous even if you forget all of Twisted and just look at the byte-level spec.

Your choice is not "synchronous or asynchronous interface".  It is "educate novice developers about Deferreds" or "educate novice developers about multithreaded concurrency, reactor implementation details, livelock, deadlock, and spurious reentrancy".  That's assuming that you fix any outstanding reactor bugs related to this issue, fully test the related code paths, AND there are no bugs in your wrapper layer.  Trust me: there will be bugs in your wrapper layer.  There are maybe 20 people in the world who could make Twisted do sync/async mapping *really* correctly, and all of them understand the problem too well to bother to try.




More information about the Twisted-Python mailing list