[Twisted-Python] Advice sought on application evolution

Tristan Seligmann mithrandi at mithrandi.net
Sat Mar 22 23:57:16 EDT 2008

* glyph at divmod.com <glyph at divmod.com> [2008-03-23 03:48:23 -0000]:

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

That's a pretty nice description, I think I'll file that one away; I
haven't actually used inlineCallbacks (or defgen) in any real code, but
back before I discovered Twisted, I wrote an application where I was
using Stackless in a fashion similar to inlineCallbacks to sequence
operations that had to be performed in a fairly complex and sequential
order. Each step was broken down into its own code, and then it was all
put together in a "master" function, which I would have written with
inlineCallbacks in Twisted code.

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

The corollary(?) to this is that if your normal deferred/callback-code
feels too awkward, perhaps you need to break it down into
better-contained logical units, rather than trying to smush it all
together inlineCallbacks-style.
mithrandi, i Ainil en-Balandor, a faer Ambar
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20080323/d8e80488/attachment.pgp 

More information about the Twisted-Python mailing list