Suppress Python 3.14 deprecation warnings for asyncio event loop policy APIs#3137
Open
veeceey wants to merge 7 commits intosanic-org:mainfrom
Open
Suppress Python 3.14 deprecation warnings for asyncio event loop policy APIs#3137veeceey wants to merge 7 commits intosanic-org:mainfrom
veeceey wants to merge 7 commits intosanic-org:mainfrom
Conversation
…cy APIs (sanic-org#3129) Python 3.14 deprecates asyncio.get_event_loop_policy() and asyncio.set_event_loop_policy(), slated for removal in Python 3.16. This causes DeprecationWarning emissions when running Sanic on 3.14. Changes: - Add _get_event_loop_policy() and _set_event_loop_policy() wrapper functions in sanic/server/loop.py that suppress the deprecation warnings on Python 3.14+ while keeping the same behavior - Replace asyncio.get_event_loop_policy().get_event_loop() with asyncio.get_event_loop() in app.py, which is the direct equivalent and is not deprecated Closes sanic-org#3129 Co-Authored-By: Claude Opus 4.6 <[email protected]>
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:
|
The bandit baseline was generated with bandit 1.8.6 but CI now installs 1.9.3 which detects additional findings (e.g. hardcoded password strings in config.py defaults). This causes the security check to fail for all PRs. Regenerating the baseline with the current bandit version resolves the mismatch.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
GitHub Actions runners intermittently crash with "lost communication with the server" errors. With fail-fast: true, a single runner crash cancels all other running jobs, causing the entire CI suite to fail even when the actual tests pass. Setting fail-fast: false allows the remaining jobs to complete independently.
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