
On Tue, 19 Feb 2019 at 11:01, Chris Withers <chris@withers.org> wrote:
Hi All,
There's this assert:
https://github.com/twisted/twisted/blob/trunk/src/twisted/internet/defer.py#...
...and I'd like to understand why it's there.
[snip]
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.
I think it was introduced to catch some common bad usage patterns ... like yours :) If you want to chain the deferreds, use the dedicated helper https://twistedmatrix.com/documents/current/core/howto/defer.html#chaining-d... Deferred are not always 100% resolved/called. You might have a deferred called, but the current result might be another deferred... so it has no final result yet. ---- so in your case, instead of `returnValue(result)` use result = yield result returnValue(result) in this way, the result is resolved :) Hope it helps -- Adi Roiban