Convert inlineCallback code to standard Twisted way

Bug #947260 reported by Duncan McGreggor
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Accomplishments Daemon
Fix Released

Bug Description

inlineCallbacks are slow, and not encouraged for general use. Despite being easier for non-Twisted programmers to read, they are innefficient execution-wise, and limit the sorts of things that can be done (due to one-yeild-per-method).

Revision history for this message
Jono Bacon (jonobacon) wrote :

Thanks for the bug, Duncan.

Can you explain why inlineCallbacks are slow and not encouraged and what the alternative would be? Thanks!

Changed in ubuntu-accomplishments-system:
status: New → Incomplete
importance: Undecided → Low
Revision history for this message
Duncan McGreggor (oubiwann) wrote :

inlineCallbacks are really easy to misuse (see general warning here:

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:; note that JP/exarkun is the primary maintainer of Twisted)
4) they can be hard to debug (see,,,
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...)

Jono Bacon (jonobacon)
affects: ubuntu-accomplishments-system → ubuntu-accomplishments-daemon
Revision history for this message
Jono Bacon (jonobacon) wrote :

I believe that Rafal has fixed this.

Changed in ubuntu-accomplishments-daemon:
status: Incomplete → Fix Committed
Changed in ubuntu-accomplishments-daemon:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.