Windows: no running event loop as of 22.3.0
See original GitHub issueDescribe the bug
Hey, heads up, after updating to 22.3.0
a sanic server no longer starts on my Windows machine. Instead raises a RuntimeError: no running event loop
. Seen this on two separate Windows machines so far.
Code snippet
# main.py
import sanic
app = sanic.Sanic("foo")
@app.get("/bar")
async def _(request):
return sanic.response.text("buzz")
app.run(host="127.0.0.1", port=1337, access_log=False)
$ pipenv run python main.py
[2022-04-04 13:33:34 +0100] [14080] [INFO]
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Sanic v22.3.0 β
β Goin' Fast @ http://0.0.0.0:1337 β
βββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ€
β β mode: production, single worker β
β ββββ βββββ ββ β server: sanic β
β ββ β python: 3.9.2 β
β ββββββββ ββββ β platform: Windows-10-10.0.22000-SP0 β
β ββ β packages: sanic-routing==22.3.0 β
β ββββ βββββββββ β β
β β β
β Build Fast. Run Fast. β β
βββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββ
[2022-04-04 13:33:34 +0100] [14080] [WARNING] Sanic is running in PRODUCTION mode. Consider using '--debug' or '--dev' while actively developing your application.
[2022-04-04 13:33:34 +0100] [14080] [ERROR] Experienced exception while trying to serve
Traceback (most recent call last):
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\mixins\runner.py", line 578, in serve
serve_single(primary_server_info.settings)
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\server\runners.py", line 206, in serve_single
serve(**server_settings)
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\server\runners.py", line 146, in serve
ctrlc_workaround_for_windows(app)
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\compat.py", line 91, in ctrlc_workaround_for_windows
app.add_task(stay_active)
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\app.py", line 1217, in add_task
loop = self.loop # Will raise SanicError if loop is not started
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\app.py", line 255, in loop
return get_running_loop()
RuntimeError: no running event loop
Traceback (most recent call last):
File "C:\Users\James\Desktop\test\main.py", line 9, in <module>
app.run(host='0.0.0.0', port=1337, access_log=False)
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\mixins\runner.py", line 145, in run
self.class.serve(primary=self) # type: ignore
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\mixins\runner.py", line 578, in serve
[2022-04-04 13:40:57 +0100] [22748] [WARNING] Sanic is running in PRODUCTION mode. Consider using '--debug' or '--dev' while actively developing your application.
[2022-04-04 13:40:57 +0100] [22748] [ERROR] Experienced exception while trying to serve
Traceback (most recent call last):
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\mixins\runner.py", line 578, in serve
serve_single(primary_server_info.settings)
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\server\runners.py", line 206, in serve_single
serve(**server_settings)
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\server\runners.py", line 146, in serve
ctrlc_workaround_for_windows(app)
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\compat.py", line 91, in ctrlc_workaround_for_windows
app.add_task(stay_active)
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\app.py", line 1217, in add_task
loop = self.loop # Will raise SanicError if loop is not started
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\app.py", line 255, in loop
return get_running_loop()
RuntimeError: no running event loop
Traceback (most recent call last):
File "C:\Users\James\Desktop\test\main.py", line 9, in <module>
app.run(port=1337, access_log=False)
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\mixins\runner.py", line 145, in run
self.class.serve(primary=self) # type: ignore
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\mixins\runner.py", line 578, in serve
serve_single(primary_server_info.settings)
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\server\runners.py", line 206, in serve_single
serve(**server_settings)
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\server\runners.py", line 146, in serve
ctrlc_workaround_for_windows(app)
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\compat.py", line 91, in ctrlc_workaround_for_windows
app.add_task(stay_active)
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\app.py", line 1217, in add_task
loop = self.loop # Will raise SanicError if loop is not started
File "C:\Users\James\.virtualenvs\test-lP8LJtvX\lib\site-packages\sanic\app.py", line 255, in loop
return get_running_loop()
RuntimeError: no running event loop
Environment (please complete the following information):
- OS: Windows 11 Pro
- Version 10.0.22000 build 22000
- Python: 3.9.2
Issue Analytics
- State:
- Created a year ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
"RuntimeError: no running event loop" with "asyncio ...
If there is no running event loop a RuntimeError is raised. This function can only be called from a coroutine or a callback....
Read more >Changelog β Sanic 22.9.1 documentation
This allows blueprints to be pickled and unpickled, without errors, which is a requirement of running Sanic in multiprocessing mode in Windows. Added...
Read more >22.3.0 no running event loop - Sanic Community Discussion
I got a error when upgrate sanic to 22.3.0.
Read more >Event Loop β Python 3.11.1 documentation
The loop must not be running when this function is called. Any pending callbacks will be discarded. This method clears all queues and...
Read more >22.3.0 - GraalVM
Released the LLVM runtime for GraalVM Community Edition for Windows under experimental support. Updated the OpenJDK release on which GraalVMΒ ...
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 is this issue: https://github.com/sanic-org/sanic-ext/issues/70
Patch coming later today
v22.3.1 should resolve this and has been released. Feedback π or π would be appreciated.