Module:core.async_helpers

Async helper function that are invalid syntax on Python 3.5 and below.

This code is best effort, and may have edge cases not behaving as expected. Inparticular it contain a number of heuristics to detect whether code iseffectively async and need to run in an event loop or not.

Some constructs (like top-levelreturn, oryield) are taken care ofexplicitly to actually raise a SyntaxError and stay as close as possible toPython semantics.

1 Function

IPython.core.async_helpers.get_asyncio_loop()

asyncio has deprecated get_event_loop

Replicate it here, with our desired semantics:

  • always returns a valid, not-closed loop

  • not thread-local like asyncio’s,because we only want one loop for IPython

  • if called from inside a coroutine (e.g. in ipykernel),return the running loop

Added in version 8.0.