Skip to content
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

Cannot use Ctrl + C to exit the program normally #2986

Open
1 task done
lky1937 opened this issue Jul 16, 2024 · 0 comments
Open
1 task done

Cannot use Ctrl + C to exit the program normally #2986

lky1937 opened this issue Jul 16, 2024 · 0 comments
Labels

Comments

@lky1937
Copy link

lky1937 commented Jul 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Use Ctrl + C to interrupt the program when the program startup is not complete, and subsequent Ctrl + C will fail.

The operation procedure and related logs are as follows:

  1. Use Ctrl + C for the first time
    [2024-07-16 13:04:06 +0800] [19752] [INFO] Received signal SIGINT. Shutting down.
    Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/sanic/worker/serve.py", line 117, in worker_serve
    return _serve_http_1(
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/sanic/server/runners.py", line 257, in _serve_http_1
    loop.run_until_complete(app._server_event("init", "before"))
    File "uvloop/loop.pyx", line 1511, in uvloop.loop.Loop.run_until_complete
    File "uvloop/loop.pyx", line 1504, in uvloop.loop.Loop.run_until_complete
    File "uvloop/loop.pyx", line 1377, in uvloop.loop.Loop.run_forever
    File "uvloop/loop.pyx", line 555, in uvloop.loop.Loop._run
    File "uvloop/handles/poll.pyx", line 216, in uvloop.loop.__on_uvpoll_event
    File "uvloop/cbhandles.pyx", line 83, in uvloop.loop.Handle._run
    File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
    File "uvloop/loop.pyx", line 397, in uvloop.loop.Loop._read_from_self
    File "uvloop/loop.pyx", line 402, in uvloop.loop.Loop._invoke_signals
    File "uvloop/loop.pyx", line 377, in uvloop.loop.Loop._ceval_process_signals
    KeyboardInterrupt

  2. Use Ctrl + C for the second or more time
    [2024-07-16 13:04:08 +0800] [19752] [INFO] Shutdown interrupted. Killing.
    [2024-07-16 13:04:08 +0800] [19752] [INFO] Killing Sanic-Server-0-0 [19757]
    [2024-07-16 13:04:08 +0800] [19752] [INFO] Received signal SIGINT. Shutting down.

Code snippet

import asyncio

from sanic.app import Sanic

app = Sanic(name='test_sanic')


@app.listener('before_server_start')
async def before_server_start(app, loop):
    await asyncio.sleep(5)

Expected Behavior

No response

How do you run Sanic?

Sanic CLI

Operating System

MacOS

Sanic Version

23.12.2

Additional context

No response

@lky1937 lky1937 added the bug label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant