Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3122 +/- ##
=============================================
- Coverage 87.957% 87.811% -0.146%
=============================================
Files 105 105
Lines 8113 8139 +26
Branches 1287 1290 +3
=============================================
+ Hits 7136 7147 +11
- Misses 671 686 +15
Partials 306 306 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #2948 by adding robust error handling for connection failures during worker shutdown, particularly when processes are terminated rapidly (double kill scenario with uvloop).
Key changes:
- Added exception handling for multiprocess connection errors (BrokenPipeError, ConnectionResetError, EOFError) across worker state operations
- Introduced
_run_shutdown_coro()function to handle event loop state issues during shutdown, with special handling for uvloop's behavior where the firstrun_until_complete()afterloop.stop()may fail - Added signal handler cleanup before shutdown to prevent issues during the shutdown sequence
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| sanic/worker/process.py | Extended exception handling in exit() to catch additional connection errors (BrokenPipeError, ConnectionResetError, EOFError); wrapped set_state() call in terminate() with similar exception handling to prevent crashes when monitor process has exited |
| sanic/server/runners.py | Added _run_shutdown_coro() helper function to handle running shutdown coroutines when loop has been stopped; added signal handler removal before shutdown; wrapped app.set_serving(False) with exception handling for connection errors |
| sanic/mixins/startup.py | Wrapped _get_process_states() method with exception handling to gracefully return empty list when shared state connection fails |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #2948