Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
PR #6026, which was introduced to allow for ^C interruption during long model loading sequences at startup time, inadvertently interferes with the applications shutdown event from firing correctly (see #6242). The original PR was written to address an issue with the
scan_models_on_startup
behavior. When using the in-memory database,scan_models_on_startup
, which defaulted to True, would take a long time to compute the blake3 hash of each model in themodels
directory. Because of the ASGI application's sigINT handling, this process was uninterruptable, and very painful to wait through. However, more recentlyscan_models_on_startup
defaults to False, and this is not so much of an issue.The code in this PR temporarily disables ASGI sigINT handling just before model scanning starts and reenables it right after, using a context manager. This will allow user who have
scan_models_on_startup
set to True to interrupt the program without interfering with routine shutdown handling.Related Issues / Discussions
QA Instructions
Follow the recipe in #6242 to enable a print statement when the application shuts down. Launch the app, wait for it to settle down, then hit ^C. You should see the print statement output.
Merge Plan
Merge when approved.
Checklist