Since @inlineCallbacks are decorators, odd errors pop up if you misuse them.
@inlineCallback but don't call yield:
You'll see this misleading error at runtime:
2010-01-28 16:32:55-0800 [-] [user_notification] File "/Users/hubbard/code/ve/dx/lib/python2.6/site-packages/twisted/internet/defer.py", line 746, in _inlineCallbacks 2010-01-28 16:32:55-0800 [-] [user_notification] result = g.send(result) 2010-01-28 16:32:55-0800 [-] [user_notification] exceptions.AttributeError: 'NoneType' object has no attribute 'send'
and wonder why, since you might not be sending anything. Yep, just remove the decorator or check for a missing yield statement.
yield but no @inlineCallback
Komodo will catch this in the editor, thankfully. Not sure what'd happen at runtime, though I suspect a hang since yield is also used for generators and is a valid Python keyword.
return from an @inlineCallback function
Yep, the decorator hijacks the return statement. You need to use
1 2 3 | controller.py:from twisted.internet.defer import inlineCallbacks, returnValue ... returnValue(ans) |
(Komodo will catch this. I like Komodo. You might like it too.)
returnValue from non-decorated function
Unknown. Komodo misses this error, surprisingly.