Skip to content

Clean up synchronous managers #755

@blink1073

Description

@blink1073

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 and concurrent.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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions