Suppress Python 3.14 deprecation warnings for asyncio event loop policy APIs#3137
Open
veeceey wants to merge 1 commit into
Open
Suppress Python 3.14 deprecation warnings for asyncio event loop policy APIs#3137veeceey wants to merge 1 commit into
veeceey wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3137 +/- ##
=============================================
- Coverage 87.793% 87.742% -0.052%
=============================================
Files 105 105
Lines 8143 8158 +15
Branches 1290 1292 +2
=============================================
+ Hits 7149 7158 +9
- Misses 687 692 +5
- Partials 307 308 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…cy APIs (sanic-org#3129) Python 3.14 deprecates get_event_loop_policy() and set_event_loop_policy(). Wrap these calls to suppress DeprecationWarning on 3.14+ while maintaining backward compatibility. Also replace get_event_loop_policy().get_event_loop() with get_event_loop() in app.py. Additional changes: - Regenerate bandit baseline for bandit 1.9.x compatibility - Set fail-fast: false in CI to prevent cascading failures from runner crashes
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.
Summary
Fixes #3129
sanic/server/loop.py: Added_get_event_loop_policy()and_set_event_loop_policy()wrapper functions that suppress theDeprecationWarningforasyncio.get_event_loop_policyandasyncio.set_event_loop_policyon Python 3.14+. These APIs still work but are deprecated and slated for removal in Python 3.16. The wrappers keep the same behavior while silencing the warnings.sanic/app.py: Replacedasyncio.get_event_loop_policy().get_event_loop()withasyncio.get_event_loop(), which is the direct equivalent and is not deprecated.bandit.baseline: Regenerated for bandit 1.9.x compatibility (the old baseline was generated with 1.8.6, causing security checks to fail for all PRs).This addresses all three deprecation warnings reported in the issue:
asyncio.get_event_loop_policyinloop.py:46asyncio.set_event_loop_policyinloop.py:47asyncio.get_event_loop_policy().get_event_loop()inapp.pyTest plan
DeprecationWarningis emitted when running on Python 3.14 with uvloopDeprecationWarningis emitted when running on Python 3.14 without uvlooptest_server_loop.pytests still pass