"RuntimeError: This event loop is already running" When attempting REPL example
See original GitHub issueEach time I attempt the REPl example, I get the traceback below. Sync context-manager example worked though.
playwright==0.8.0
REPL Example: https://github.com/microsoft/playwright-python#repl-support-without-context-managers
IPython session
jake (e) venvplaywright ~ ipython
/home/jake/.local/lib/python3.8/site-packages/IPython/core/interactiveshell.py:935: UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
warn("Attempting to work in a virtualenv. If you encounter problems, please "
Python 3.8.3 (default, May 29 2020, 00:00:00)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from playwright import sync_playwright
In [2]: playwright = sync_playwright().start()
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 11, in <module>
sys.exit(start_ipython())
File "/home/jake/.local/lib/python3.8/site-packages/IPython/__init__.py", line 126, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/home/jake/.local/lib/python3.8/site-packages/traitlets/config/application.py", line 664, in launch_instance
app.start()
File "/home/jake/.local/lib/python3.8/site-packages/IPython/terminal/ipapp.py", line 356, in start
self.shell.mainloop()
File "/home/jake/.local/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 558, in mainloop
self.interact()
File "/home/jake/.local/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 541, in interact
code = self.prompt_for_code()
File "/home/jake/.local/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 467, in prompt_for_code
text = self.pt_app.prompt(
File "/home/jake/.local/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 994, in prompt
return self.app.run(set_exception_handler=set_exception_handler)
File "/home/jake/.local/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 811, in run
return loop.run_until_complete(
File "/usr/lib64/python3.8/asyncio/base_events.py", line 592, in run_until_complete
self._check_running()
File "/usr/lib64/python3.8/asyncio/base_events.py", line 552, in _check_running
raise RuntimeError('This event loop is already running')
RuntimeError: This event loop is already running
If you suspect this is an IPython 7.13.0 bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True
sys:1: RuntimeWarning: coroutine 'Application.run_async' was never awaited
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:40 (4 by maintainers)
Top Results From Across the Web
RuntimeError: This event loop is already running in python
The loop doesn't return control to the code following the first instance of run_until_complete() until second function completes (thus no code ...
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 >no running event loop sys:1: runtimewarning: coroutine 'loop ...
The loop was just created and it's not running yet, therefor the asyncio unable to attach tasks to it. The following example will...
Read more >How to get around “RuntimeError: This event loop is already ...
Asyncio does not allow its event loop to be nested. So if you are in an environment where the event loop is already...
Read more >Python Language Summit Lightning Talks, Part 1
This call raises “RuntimeError: This event loop is already running.” As Fried explained, any call to run_until_complete() in a call chain ...
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
It’s been almost two years and this still isn’t fixed that I can find - playwright is explicitly stopping me from using nested loops:
The workarounds don’t work for those of us using windows, and they don’t appear to work in WSL either - is there a reason we can’t get more information on why this is still closed two years later with no traction and no functional workarounds for presumably a fairly normal use case of using a jupyter notebook for exploratory programming?
It seems hard to believe that we just assume everyone will use raw iPython for everything so I’m confused by the reluctance to actually fix this.
If I’m understanding the asyncio base_events.py error, it’s because there’s no implementation of the
_make_subprocess_transport
function - is that not something that would be on theplaywright
package to implement in it’s async implementation?If I get time tonight ill play around with it- I dont see any reason for it not to run in the existing loop - or are there architectural challenges with it sharing the loop?
On Tue, Oct 6, 2020, 8:35 AM Pavel Feldman notifications@github.com wrote: