Skip to content

Program not closing on Ctrl+C on Windows #282

@Astremy

Description

@Astremy

Using the development server with the latest Quart 0.19.3 and Python 3.10.1 on Windows 10, using ctrl-c to stop the server correctly shutdowns the tcp server and active connections but doesn't exits. The program hangs and can only be stopped via the task manager or by closing the terminal window.

Using the following minimal program, simply run it and then ctrl-c it

from quart import Quart
app = Quart(__name__)
app.run()

There is no logs beside the intro message, no traceback, hitting ctrl-c multiple times just does nothing.

 * Serving Quart app 'app'
 * Debug mode: True
 * Please use an ASGI server (e.g. Hypercorn) directly in production
 * Running on http://127.0.0.1:5000 (CTRL + C to quit)
[2023-10-08 12:01:49 +0200] [19356] [INFO] Running on http://127.0.0.1:5000 (CTRL + C to quit)

Environment:

  • OS: Windows
  • Python version: 3.10.1
  • Quart version: 0.19.3

Investigation:

Our investigation leaded us to this commit 68da65c.
The _windows_signal_support() coroutine loops forever, that coroutine is saved in a tasks along with the actual server task. Later on all the tasks from that list are asyncio.gather together, since asyncio.gather only returns when all coroutines returns and that _windows_signal_support() will never returns, the program hangs waiting for that coroutine forever.

That _windows_signal_support() says to be fixing a pre-3.8 bug, since Quart doesn't support 3.7 since 0.19.0, maybe this function is not needed anymore.

cc @Julien00859

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions