Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes an infinite loop issue in the shutdown process by ensuring the event loop is properly passed to shutdown_tasks(). The problem occurred because get_running_loop() was being called from outside a running coroutine context, causing it to fail silently and skip the sleep operation.
Key Changes:
- Pass the event loop explicitly from
_cleanup()in runners.py toshutdown_tasks() - Add optional
loopparameter toshutdown_tasks()with fallback logic to obtain the loop if not provided - Improve the while loop condition to check
timeout > 0instead of just truthiness
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| sanic/server/runners.py | Passes the event loop to shutdown_tasks() call during cleanup to ensure proper loop availability |
| sanic/app.py | Adds optional loop parameter to shutdown_tasks() method with fallback logic and refactors loop acquisition and exception handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3123 +/- ##
=============================================
- Coverage 87.793% 87.789% -0.004%
=============================================
Files 105 105
Lines 8143 8149 +6
Branches 1290 1291 +1
=============================================
+ Hits 7149 7154 +5
- Misses 687 689 +2
+ Partials 307 306 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <[email protected]>
Closes #2906
shutdown_tasks() was using get_running_loop() which fails when called outside of a running coroutine, causing the sleep to be silently skipped, creating an infinite loop.