Comment 2 for bug 947260

Revision history for this message
Duncan McGreggor (oubiwann) wrote :

inlineCallbacks are really easy to misuse (see general warning here: http://twistedmatrix.com/pipermail/twisted-python/2007-February/014869.html).

They lead coders into assumptions of familiarity that they really shouldn't have:
 1) yes, it can make Twisted code more familiar looking to those that aren't comfortable with the standard deferred/callback style, but!
 2) that cozy feeling lulls coders into thinking that they can treat their inlineCallback'ed code like other regular, "linear", blocking Python code, and this isn't correct.
 3) you still have to deal with the same sorts of complex issues that are a part of concurrent/async programming models, but with inlineCallbacks, those issues are disguised (due to not being explicit in the code; for one example of this, see JP's comment here: http://stackoverflow.com/questions/5972664/python-twisted-iterators-and-yields-inlinecallbacks; note that JP/exarkun is the primary maintainer of Twisted)
4) they can be hard to debug (see http://twistedmatrix.com/trac/ticket/4157, http://twistedmatrix.com/trac/ticket/5269, http://twistedmatrix.com/trac/ticket/3622, http://twistedmatrix.com/trac/ticket/5178)
5) JP, primary Twisted maintainer, actually has given presentations on all the ways in which inlineCallbacks can (and will) go wrong. He's still waiting to prepare his slide deck for public consumption, and I can update this ticket when he does.

Sugar on top: the original author of inlineCallbacks once cursed in my presence, that he'd wished he'd never written them :-) (though he'll deny this if you ask him! You can tell him he said it at the Barcelona UDS when we were talking about txAMQP...)