Skip to content

CTRL^C doesn't work while startup in progress #1301

Open
@levsh

Description

@levsh

Checklist

  • The bug is reproducible against the latest release or master.
  • There are no similar issues or pull requests to fix it yet.

Describe the bug

Hi!

ctrl^c doesn't work until on_startup function completes. This happens because install_signal_handlers call before startup

Steps to reproduce the bug

import asyncio

import uvicorn
from fastapi import FastAPI

async def on_startup():
    for _ in range(10):
        await asyncio.sleep(1)

app = FastAPI(on_startup=[on_startup])

if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=5000, log_level="info")

Expected behavior

No response

Actual behavior

No response

Debugging material

No response

Environment

uvicorn - 0.16.0
python - 3.8.6

Additional context

No response

Important

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions