[Twisted-Python] Some things I've learned: safer callbacks, better t.p.context

Amber "Hawkie" Brown hawkowl at atleastfornow.net
Wed Oct 19 17:43:58 MDT 2016


> On 20 Oct. 2016, at 08:54, Glyph Lefkowitz <glyph at twistedmatrix.com> wrote:
> 
> 
>> On Oct 19, 2016, at 2:47 PM, Itamar Turner-Trauring <itamar at itamarst.org <mailto:itamar at itamarst.org>> wrote:
>> 
>> On Wed, Oct 19, 2016, at 05:45 PM, Itamar Turner-Trauring wrote:
>>> Well... I had a test that went through synchronous Deferred path. And yeah, it was easier to write than async test. But it failed to catch a bug that was only in async case. So the problem I see is that supporting both in Deferred means you need twice the number of tests each time you use Deferreds.
>> 
>> Er, that was unclear. I had a bug that wasn't caught by tests because it passed with sync Deferred and failed with async Deferred callback, and I didn't have tests for latter.
> 
> 
> To be clear: I do see this as a downside to Deferred's architecture; it's a tradeoff.  I see the loose coupling with the event loop as a worthwhile upside.

One thing that I have still not figured out is how Futures (which are tightly tied to an event loop) will possibly ever work over multiple event loops. I think since you can't really chain them, this is less of a problem, but Deferreds like to absorb other Deferreds and make one big one, which would make the tight coupling problematic if you wanted to use two event loops (like, say, a GTK one and an IOCP one on Windows).

- Amber

> 
> However, it's totally possible to write the async Deferred callback case as well, just by having the test fire the Deferred after returning to the test body instead of firing it before :-).
> 
> -glyph
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20161020/0eb80b1d/attachment-0002.html>


More information about the Twisted-Python mailing list