Re: [Async-sig] Inadvertent layering of synchronous code as frameworks adopt asyncio

2019-03-26 Thread Glyph
> On Mar 26, 2019, at 11:56 AM, Yury Selivanov wrote: > > >> On Mar 25, 2019, at 8:01 PM, Guido van Rossum > > wrote: >> >> Given PBP, I wonder if we should just relent and have a configurable flag >> (off by default) to allow nested loop invocations (both the same l

Re: [Async-sig] Inadvertent layering of synchronous code as frameworks adopt asyncio

2019-03-26 Thread Glyph
> On Mar 26, 2019, at 11:36 AM, Guido van Rossum wrote: > > Maybe running two *independent* loops should just always be allowed? As was > said, it should be no worse than calling requests.get(). There currently is > an explicit check against this -- deleting that check seems to make this > wor

Re: [Async-sig] Inadvertent layering of synchronous code as frameworks adopt asyncio

2019-03-26 Thread Nathaniel Smith
On Mon, Mar 25, 2019 at 4:37 PM Guido van Rossum wrote: > > I also hope Nathaniel has something to say -- I wonder if trio supports > nested event loops? Trio does have a similar check to prevent starting a new Trio loop inside a running Trio loop, and there's currently no way to disable it: ht

Re: [Async-sig] Inadvertent layering of synchronous code as frameworks adopt asyncio

2019-03-26 Thread Yury Selivanov
> On Mar 25, 2019, at 8:01 PM, Guido van Rossum wrote: > > Given PBP, I wonder if we should just relent and have a configurable flag > (off by default) to allow nested loop invocations (both the same loop and a > different loop). > I think that if we implement this feature behind a flag the

Re: [Async-sig] Inadvertent layering of synchronous code as frameworks adopt asyncio

2019-03-26 Thread Guido van Rossum
Maybe running two *independent* loops should just always be allowed? As was said, it should be no worse than calling requests.get(). There currently is an explicit check against this -- deleting that check seems to make this work, as long as you close the nested loop explicitly. (This may be someth

Re: [Async-sig] Inadvertent layering of synchronous code as frameworks adopt asyncio

2019-03-26 Thread Daniel Nugent
Not sure if it helps, but I got something working for the problem I was experiencing by detecting if there was a currently running event loop, and then at the synchronous call points, creating and running a new loop on a separate thread. This makes the object in question synchronous or asynchron