RuntimeError: Cannot enter into task
See original GitHub issueHi,
thanks for this amazing package, this was for me the reason to adopt asyncio (otherwise the maintenance burden was too high).
I sometimes see this error in CI systems, and have trouble reproducing it locally:
Traceback (most recent call last):
File "/Users/maartenbreddels/miniconda3/envs/dev/lib/python3.7/site-packages/nest_asyncio.py", line 149, in run
ctx.run(self._callback, *self._args)
RuntimeError: Cannot enter into task <Task pending coro=<_debounced_callable.__call__.<locals>.debounced_execute.<locals>.run_async() running at /Users/maartenbreddels/src/vaex/packages/vaex-core/vaex/jupyter/utils.py:149>> while another task <Task pending coro=<InteractiveShell.run_cell_async() running at /Users/maartenbreddels/miniconda3/envs/dev/lib/python3.7/site-packages/IPython/core/interactiveshell.py:3020> cb=[IPythonKernel._cancel_on_sigint.<locals>.cancel_unless_done(<Future pendi...ernel.py:230]>)() at /Users/maartenbreddels/miniconda3/envs/dev/lib/python3.7/site-packages/ipykernel/ipkernel.py:230, IOLoop.add_future.<locals>.<lambda>() at /Users/maartenbreddels/miniconda3/envs/dev/lib/python3.7/site-packages/tornado/ioloop.py:690]> is being executed.
I wonder if you have any idea what can cause this so I can try to reproduce it and open a proper issue (or fix it).
cheers,
Maarten
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
RuntimeError: Cannot enter into task · Issue #12803 - GitHub
Description Certain notebooks raise an exception when they are opened: RuntimeError: Cannot enter into task. This is an intermittent error.
Read more >Cannot enter into task while another task is being executed ...
I am using FastAPI, and strangely, only on the first API call I get the error "RuntimeError: Cannot enter into task while another...
Read more >Source code for asyncio.tasks - Sphinx Book Theme
"""Support for tasks, coroutines and the scheduler. ... current_task is not None: raise RuntimeError(f"Cannot enter into task {task!r} while ...
Read more >Common Mistakes Using Python3 asyncio
RuntimeWarning: coroutine foo was never awaited; 3. Task was destroyed but it is pending! 4. Task/Future is awaited in a different EventLoop than...
Read more >Python Jupyter Lab で RuntimeError: Cannot enter into task <1 ...
Description Certain notebooks raise an exception when they are opened: RuntimeError: Cannot enter into task. This is an intermittent error.
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 FreeTop 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
Top GitHub Comments
For my understanding (and possibly others), this simple script will trigger this exception:
Which gives the following output:
Note that this confirms what @erdewit was saying, it will be triggered when asyncio machinery wants to resume a task that is unpatched (i.e. created before .apply() was called).
Hopefully, this will help to debug similar issues.
This error is indicative of an unpatched Task. It could be similar to the unpatched Future from #23, were it gets imported before nest_asyncio has patched
asyncio.Task
.If possible, do the import and application of nest_asyncio before importing other modules.