[Twisted-Python] why can't a callback be called with a deferred?

Chris Withers chris at withers.org
Tue Feb 19 04:00:57 MST 2019


Hi All,

There's this assert:

https://github.com/twisted/twisted/blob/trunk/src/twisted/internet/defer.py#L459

...and I'd like to understand why it's there.

I have what feels like a legitimate case where that assert trips me up, 
as I'd like to change this line:

https://github.com/cjw296/carly/blob/d39e316aa0f9e05613c263410e7b3ba5bcacba3a/carly/hook.py#L67

...to just return result.value. However, if the method being hooked 
returns a deferred, then I trip the assert.
Unfortunately, the commit that introduced that assert is just a one 
liner from Itamar back in 2003 without any context of what problem lead 
him to introduce the change.

Of course, I can work around it, was more curious than anything...

Chris



More information about the Twisted-Python mailing list