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

fix(api): stop other servers if one exited #187

Merged
merged 1 commit into from
Apr 23, 2024
Merged

fix(api): stop other servers if one exited #187

merged 1 commit into from
Apr 23, 2024

Conversation

efiop
Copy link
Contributor

@efiop efiop commented Apr 23, 2024

gather doesn't cancel other tasks automatically, e.g. causing metrics server to keep running if user app failed to setup().

Caused by #31

@efiop efiop force-pushed the fix-31 branch 2 times, most recently from d1890a3 to 395e5af Compare April 23, 2024 10:44
Comment on lines -915 to -927
event = asyncio.Event()
# TODO(squat): handle shutdowns gracefully.
# You cannot add signal handlers to any loop if you're not
# on the main thread.
# How can we detect that we are being shut down and stop the
# uvicorn servers gracefully?
# loop = asyncio.get_running_loop()
# loop.add_signal_handler(signal.SIGINT, event.set)
# loop.add_signal_handler(signal.SIGTERM, event.set)
await asyncio.gather(
server.serve_until_event(event),
metrics_server.serve_until_event(event),
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that even serve() itself is not in the main thread - it is not our obligation to set the signal handler here anyway, so we can ignore it for now. Removing these leftovers to not obstruct the view.

@efiop efiop requested a review from squat April 23, 2024 10:54
`gather` doesn't cancel other tasks automatically, e.g. causing metrics
server to keep running if user app failed to `setup()`.

Caused by #31
@efiop
Copy link
Contributor Author

efiop commented Apr 23, 2024

For the record: timeout errors are unrelated.

Merging for now to have it operational in the upstream.

@efiop efiop merged commit e64aba8 into main Apr 23, 2024
4 of 5 checks passed
@efiop efiop deleted the fix-31 branch April 23, 2024 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant