Skip to content

fix: graceful SIGINT on server#2831

Merged
ashwinb merged 1 commit intollamastack:mainfrom
leseb:signal-2
Jul 21, 2025
Merged

fix: graceful SIGINT on server#2831
ashwinb merged 1 commit intollamastack:mainfrom
leseb:signal-2

Conversation

@leseb
Copy link
Collaborator

@leseb leseb commented Jul 21, 2025

What does this PR do?

After #2818, SIGINT will print a stack trace. This is because uvicorn re-raises SIGINT and it gets converted by Python internal signal handler (default handles SIGINT) to KeyboardInterrupt exception. We know simply catch the exception to get a clean exit, this is not changing the behavior on SIGINT.

Test Plan

Run the server, hit Ctrl+C or kill -2 <server pid> and expect a clean exit with no stack trace.

After llamastack#2818, SIGINT will
print a stack trace. This is because uvicorn re-raises SIGINT and it
gets converted by Python internal signal handler (default handles
SIGINT) to KeyboardInterrupt exception. We know simply catch the
exception to get a clean exit, this is not changing the behavior on
SIGINT.

Signed-off-by: Sébastien Han <seb@redhat.com>
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 21, 2025
@mattf
Copy link
Collaborator

mattf commented Jul 21, 2025

@ashwinb @leseb what about changing the approach in #2812? instead of allowing initialize to start whatever it wants, it could register_task (a new "InlineTaskProtocol") that get run by the main server loop. this will given the server more control over how resources are used.

@ashwinb
Copy link
Contributor

ashwinb commented Jul 21, 2025

@ashwinb @leseb what about changing the approach in #2812? instead of allowing initialize to start whatever it wants, it could register_task (a new "InlineTaskProtocol") that get run by the main server loop. this will given the server more control over how resources are used.

I think those could be complementary. In general, we should keep the lifetimes of the provider and the server synchronized. What you propose (re: other lifecycle methods) is certainly a good idea but that could be done in addition to this.

Copy link
Contributor

@ashwinb ashwinb left a comment

Choose a reason for hiding this comment

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

ah thank you. I got confused too seeing the new stacktraces but didn't pay close attention :)

@ashwinb ashwinb merged commit 019ddda into llamastack:main Jul 21, 2025
76 of 77 checks passed
@leseb leseb deleted the signal-2 branch July 21, 2025 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants