Skip to content

docs: clarify autoawait example requires running event loop#15216

Open
SAY-5 wants to merge 1 commit into
ipython:mainfrom
SAY-5:docs/autoawait-aiohttp-loop
Open

docs: clarify autoawait example requires running event loop#15216
SAY-5 wants to merge 1 commit into
ipython:mainfrom
SAY-5:docs/autoawait-aiohttp-loop

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 21, 2026

Fixes #14865.

The aiohttp.ClientSession() example in autoawait.rst raises RuntimeError: no running event loop because cell In [1] contains no await, so IPython has not yet started the loop when ClientSession() is constructed.

Per @Carreau's suggestion on the issue ("the easier way to force a loop is to await a dummy thing, like await sleep(0)"), this prepends await asyncio.sleep(0) to the first cell and adds a short note explaining why it is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation for autoawait gives example that doesn't work

1 participant