Async error: event loop already running
See original GitHub issueNot sure this is an IPython issue because it happens only in a Jupyter Notebook, but the following code gives a RuntimeError: This event loop is already running
(IPython 7.0.1, Python 3.7.0, notebook server 5.7.0). No problem with IPython 7.0.1, Python 3.6.3, notebook server 5.3.1.
import asyncio
async def foo():
await asyncio.sleep(1)
print('done')
loop = asyncio.get_event_loop()
loop.run_until_complete(foo())
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
RuntimeError: This event loop is already running in python
One way is to pass in a synchronous callback to be called once the async operation finishes. That will of course slow down...
Read more >How to get around “RuntimeError: This event loop is already ...
The solution was to use nest-asyncio. This package patches “asyncio” and allows nested usage “loop. run_until_complete”. I have simply patched ...
Read more >Supporting asyncio.get_event_loop().run_until_complete() in ...
The above tries to use get_running_loop() first to fetch the currently running event loop, but if there's not one, it uses get_event_loop() ...
Read more >RuntimeError: This event loop is already running in python
PYTHON : RuntimeError: This event loop is already running in python [ Gift : Animated Search Engine ...
Read more >Running asyncio — Mastering JupyterLab - NO Complexity
But it can be done. If done wrong the error message: This event loop is already running appears. For any asyncio functionality ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Having this a the beginning of your notebook should fix this issue:
Yes, is is documented in the what’s new and auto-async documentation with pointer to workarounds.
Thanks for testing IPython 7.0 !