-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RuntimeError: Event loop stopped before Future completed. #2948
Comments
I do not think there is anything wrong,but I also cannot replicated this behavior. |
Someone ( import asyncio
from sanic import Sanic
from sanic.response import text
Sanic.START_METHOD_SET = True
Sanic.start_method = "fork"
async def index(request):
return text("dummy")
async def wait_some_time(app, loop):
"""Operations to perform on server shutdown.
For demo just a sleep"""
await asyncio.sleep(5)
def make_app() -> Sanic:
app = Sanic(name="dummy")
app.add_route(index, "/")
app.register_listener(wait_some_time, "before_server_stop")
return app
def run_server():
app = make_app()
app.run(host="0.0.0.0", port=8000)
if __name__ == "__main__":
run_server() |
Yes. Facing the same, can't gracefully shut down my tasks due to this issue. |
Having the same issue... |
I'm having the same issue with a simple hello world get route. If no request is issued to the server then a Ctrl+C shuts down gracefully but as soon as a request is issued, a Ctrl+C errors with the message: ERROR: Event loop stopped before Future completed.
|
Just an FYI, if I run the app with uvicorn, it shuts down gracefully without any issues. |
Is there an existing issue for this?
Describe the bug
Python 3.12.3
sanic-23.12.1
very often (not 100%) after restarting worker, for example:
@apt.get("/restart")
I get this output after Ctrl-C:
is this a mistake or am I doing something wrong?
Code snippet
Expected Behavior
No response
How do you run Sanic?
As a script (
app.run
orSanic.serve
)Operating System
Linux
Sanic Version
23.12.1
Additional context
No response
The text was updated successfully, but these errors were encountered: