[Twisted-Python] inlineCallbacksDecorator

Terry Jones terry at jon.es
Sun Jun 7 07:53:07 EDT 2009

Hi Maarten

>>>>> "Maarten" == Maarten ter Huurne <maarten at treewalker.org> writes:
Maarten> As far as I can see, this decorator could be applied to any
Maarten> function that returns a Deferred, not just to inlineCallbacks.

Yes, that's right, and it could be used in that case if you didn't want to
deal with the deferred you were about to return inside your method.

I wrote it specifically for inlineCallbacks because that case is a bit
different. With inlineCallbacks, the called method never has its hands on
the deferred that the caller will receive (whereas in a typical
deferred-returning method you either create the deferred yourself or call
something that does). In fact, the deferred the caller receives will
normally be returned back to the caller before the called method has
finished. Also, a return out of an inlineCallbacks function may happen at
many places (due to the hidden _DefGen_Return raise done by
defer.returnValue), so it's not as simple to arrange to do things at the
end of the method as it is in other circumstances.


More information about the Twisted-Python mailing list