[Twisted-Python] How to force synchronous behavior

glyph at divmod.com glyph at divmod.com
Sun Oct 30 18:20:12 EST 2005

On Mon, 31 Oct 2005 00:02:47 +0200 (SAST), Clive Crous <clive at darkarts.co.za> wrote:

>If I come online, and ask: "How do i use A with B" and the response is
>"Dont!", as in this thread, it shows a high level of arrogance, extreme
>presumption and an incredible 'naivety to programming' by the person
>giving that "answer".
>There always will be people who have different needs to you.
>Enforcement of usage policy on users is the realm of restrictive
>corporate use policy and software distribution licensing as one expects
>from Microsoft et al.

You're calling me arrogant and naive, and a fascist champion of policy enforcement: yet you have the gall to tell me what *I* must do with *my* freely donated time.  I didn't say "only stupid people do this" when you answered the question, or delete your message from the archives, I merely offered my opinion that it is a bad thing to do.  You are replying to my explanation of why we say things like that, not why *you* must never do so.

However, now that we're name-calling, let me suggest instead that *you* are arrogant to presume that you know more about the questions people ask about Twisted than I do (how long do you think I've been answering these, anyway?), and that you are incredibly naive about education in general.  When you have seen the same question asked a thousand times, you learn to see the question behind the question.  You understand the unseen consequences of answering it straightforwardly.  What can be a perfectly legitimate question from an intermediate or expert programmer is simply a set-up for disaster from a novice.

For example, if a 12-year-old girl asks you "can I get pregnant from sex if I only do it once", this is most likely not idle curiosity speaking.  You should not answer as accurately as possible, with equivocations about the probability.  You say "YES, YOU ABSOLUTELY WILL, WHERE IS YOUR MOTHER".  If a married couple in a fertility clinic asks you a similar question, about how difficult it is on average to conceive, it would be a good idea to just answer.

The context of this mailing list is less obvious than either of those, but I have found over time that if the poster really knows what they're doing, they will respond to my refusal with an explanation and I can offer more detail at that point - quite often they are asking a very different question than "how can I make this look synchronous", it is something like "I need to integrate with a proprietary library that will call my code synchronously and I have no access to its source code" or "I would like to use a Twisted protocol implementation from within an existing Zope2 site".

Neither of those questions are properly answered by "use deferredResult" or "use defgen".  It's complicated.

>The most common result of such narrow-minded
>programming mind-sets is the inability to complete the task at hand.
>Programs will be written, rewritten, re-factored, tossed out and
>restarted.  This cycle will never end as long as this zenith of coding
>"nirvana" remains the goal.  The tragic result of this is that
>projects repeatedly fail to reach a usable state, to the detriment of

This is exactly what happens with Twisted - you got everything right except the result, which is that *code quality goes up over time*.  It is this dedication to quality that makes the project fun and interesting to use.  Granted, breaking backwards compatibility is never fun, but we try hard to minimize the impact of that.

For a project which has a strict deadline and budgetary constraints, this is obviously a terrible tragedy.  I have seen it, I have even caused it (who hasn't?), and it's ugly.  However, this is exactly what makes open source so much fun; you don't have to get it right the first time, you don't have to get it right in 6 months, you can just keep trying and trying and trying.  Eventually you get it right and everyone thinks it's awesome.  I am sure that no current users remember the massive upheaval and 1 1/2 years it took to get the transport/protocol split properly implemented.  If we had not "rewritten, re-factored, tossed out and restarted" that code, Twisted would be nothing but a much set of libraries for Medusa today.

>I hope twisted development does not go down this path and shows
>some maturity and the ability to sustain it's own usage.  I really
>do love the twisted framework and would hate to see it dragged into a
>quagmire of self-indulgent disarray to the despair of a dedicated and
>loving user base (whom you freely admit not to care about at all).

Luckily I am also a user and my career, my reputation and my income all depend quite explicitly upon its success.  Many Twisted developers are in the same position now, so selfish motivations are more than adequate.

Seriously though, my point about not caring about the community was slightly tongue-in-cheek.  The point there is that I am not here to do your homework assignment, I am not here to do your job for you.  If you think that's what I *am* here for, then no, I don't care about you.

I am here to help you learn to use Twisted and learn to use it correctly.  If you don't like my advice, the code is all free, there are other people to answer your questions, and there is quite a bit of freely-available documentation (and even a book from O'Reilly now!).

More information about the Twisted-Python mailing list