-
Notifications
You must be signed in to change notification settings - Fork 299
Open
Labels
Description
Continued discussion from #751.
We also can't rely asyncio_run
in the future, since it relies on the deprecated global get_event_loop
and set_event_loop
.
Options for moving forward:
- Use a single private ioloop instance per manager
- The base classes will be asynchronous and call the the private async versions of functions directly as needed. We will only use futures and tasks from within async methods.
- The synchronous classes will work by wrapping the asynchronous public methods using a decorator that runs a new private asyncio loop as return asyncio.new_event_loop().run_until_complete(async_method).
- We would offer a function that wraps the async class to become synchronous, and use this ourselves
- We would have a section like:
# These methods are meant to be overridden by subclasses
async def _start_kernel(...)
- Run 'asyncio-for-sync' in a dedicated IO thread.
call_soon_threadsafe
andconcurrent.futures.Future
make this pretty doable, and in my experience simpler and more robust than using nest_asyncio. ipyparallel's sync client has worked that way for a long time. (per @minrk)
davidbrochart