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

Nathaniel Smith njs at pobox.com
Wed Mar 27 16:23:28 EDT 2019


On Wed, Mar 27, 2019 at 10:44 AM Daniel Nugent <nugend at gmail.com> wrote:
>
> FWIW, the ayncio_run_encapsulated approach does not work with the transport/protocol apis because the loop needs to stay alive concurrent with the connection in order for the awaitables to all be on the same loop.

Yeah, there are two basic approaches being discussed here: using two
different loops, versus re-entering an existing loop.
asyncio_run_encapsulated is specifically for the two-loops approach.

In this version, the outer loop, and everything running on it, stop
entirely while the inner loop is running – which is exactly what
happens with any other synchronous, blocking API. Using
asyncio_run_encapsulated(aiohttp.get(...)) in Jupyter is exactly like
using requests.get(...), no better or worse.

-n

-- 
Nathaniel J. Smith -- https://vorpus.org


More information about the Async-sig mailing list