[Twisted-Python] Advice sought on application evolution

glyph at divmod.com glyph at divmod.com
Sat Mar 22 23:48:23 EDT 2008


On 22 Mar, 01:54 pm, mithrandi at mithrandi.net wrote:
>But yes, the danger of accidentally serializing operations that don't
>need to be serialized, and not even realising it, is one of the 
>problems
>with this coding style.

As time goes on, I'm becoming a bigger fan of inlineCallbacks.

Too much serialization, even accidental serialization, trades 
comprehensibility for performance.  I think that's a reasonable place to 
start: make your system easy to understand, then make it fast once you 
know what's going on.

It's not a good place to end up, though.  So it's important to use 
inlineCallbacks for the right thing.

It's great as a high-level prototyping tool and an orchestration 
language for distributed conversations with large numbers of steps and 
coarse-grained error handling.  It's bad as a way of representing state 
machines or continuous processes.

In other words, don't implement protocols or frameworks with 
inlineCallbacks.  You should be working with higher level things that 
already return Deferreds.  A key hint that you're trying to brute-force 
a state machine: the entire body of your inlineCallbacks function is a 
loop.




More information about the Twisted-Python mailing list