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

2016-10-20 Thread Glyph Lefkowitz
> On Oct 19, 2016, at 5:12 PM, Kevin Conway wrote: > > As far as the possibility of integrating this feature into Twisted, let me > chat with my cohorts over here. Well come back with some benchmark code and a > proposal of changes for further discussion. I'll probably start a new thread > to

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

2016-10-19 Thread Kevin Conway
> What are you referring to as a "coroutine" here? A generator? Generator, yes, but used as a coroutine that both emits values and receives them. The introduction of dedicated coroutines in Python 3.5 is something I haven't updated my personal language for very well. Generator-coroutine is the te

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

2016-10-19 Thread Glyph Lefkowitz
> On Oct 19, 2016, at 4:43 PM, Amber Hawkie Brown > wrote: > > 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

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

2016-10-19 Thread Glyph Lefkowitz
> On Oct 19, 2016, at 4:25 PM, Jean-Paul Calderone > wrote: > > It's also possible to write a little bit of testing library code and get both > versions of the test nearly for free. Unfortunately, I very rarely see test > suites written that way. I think many people don't realize there are

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

2016-10-19 Thread Amber "Hawkie" Brown
> On 20 Oct. 2016, at 08:54, Glyph Lefkowitz wrote: > > >> On Oct 19, 2016, at 2:47 PM, Itamar Turner-Trauring > > 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

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

2016-10-19 Thread Jean-Paul Calderone
It's also possible to write a little bit of testing library code and get both versions of the test nearly for free. Unfortunately, I very rarely see test suites written that way. I think many people don't realize there are two cases to handle or believe testing both cases is too expensive for the

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

2016-10-19 Thread Glyph Lefkowitz
> On Oct 19, 2016, at 2:47 PM, Itamar Turner-Trauring > 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 >> wa

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

2016-10-19 Thread Itamar Turner-Trauring
On Tue, Oct 18, 2016, at 03:44 PM, Glyph Lefkowitz wrote: > > I think Deferred as it is today is a pretty good compromise between > the two positions. On the one hand it is decoupled from the event > loop. On the other - and this is important - *no Deferred-returning > API will ever call your

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

2016-10-19 Thread Itamar Turner-Trauring
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 D

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

2016-10-19 Thread Glyph Lefkowitz
> On Oct 18, 2016, at 7:09 PM, Kevin Conway wrote: > > > making such aggressive use of private APIs that it could win a contest > > about how to ensure that you break on every new release of Twisted :) > > We're very aware of that! It's one of the reasons we have the test matrix set > up to r

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

2016-10-18 Thread Kevin Conway
> making such aggressive use of private APIs that it could win a contest about how to ensure that you break on every new release of Twisted :) We're very aware of that! It's one of the reasons we have the test matrix set up to run multiple versions of Python and Twisted. I have not started on 16.X

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

2016-10-18 Thread Glyph Lefkowitz
> On Oct 18, 2016, at 4:05 PM, Kevin Conway wrote: > > > This is why twisted.python.context came to exist in the first place; I > > always wanted to attach it to Deferred somehow > > Well, it's not something we've announced yet through any official channel, > but we had to solve the context p

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

2016-10-18 Thread Kevin Conway
> This is why twisted.python.context came to exist in the first place; I always wanted to attach it to Deferred somehow Well, it's not something we've announced yet through any official channel, but we had to solve the context propagation problem at Atlassian to instrument our services with tracea

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

2016-10-18 Thread Glyph Lefkowitz
> On Oct 18, 2016, at 5:50 AM, Itamar Turner-Trauring > wrote: > > Not been doing much Twisted lately, but have been doing async stuff > elsewhere, and I've learned some useful things. Thanks for writing these up, Itamar! This sort of reflection is rare and it's always helpful :). > 1. Call

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

2016-10-18 Thread Itamar Turner-Trauring
Not been doing much Twisted lately, but have been doing async stuff elsewhere, and I've learned some useful things. 1. Callbacks should be sync or async, but never sometimes-one-sometimes-the-other. For details go read http://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/. For