Add support for Python 3.14 - #7574
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7574 +/- ##
===========================================
+ Coverage 89.94% 90.07% +0.13%
===========================================
Files 180 180
Lines 16255 16400 +145
===========================================
+ Hits 14621 14773 +152
+ Misses 1634 1627 -7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Commit message 410dcbf says we are introducing the support for python 3.13, but I think this is now stale bnecause we already introduced support for python 3.13 in pcluster 3.16.0. |
e5129f8 to
d4b56a2
Compare
| This approach is required to support Python 3.14 and maintain retrocompatibility with Python 3.8+. | ||
| """ | ||
| try: | ||
| return asyncio.get_running_loop() |
There was a problem hiding this comment.
When I started looking at this change, I remember that this creation was triggering lot of warning messages related to event loop not being closed.
That was from months ago, so may be not true anymore, but worth checking.
There was a problem hiding this comment.
I now added a event loop context manager that handles and creation and closing of loops so that these warnings do not happen.
| adding progress reporting, and supporting running on deleted clusters. | ||
|
|
||
| **CHANGES** | ||
| - Add support for Python 3.14. |
There was a problem hiding this comment.
Better to be more explicit syaing Add support for Python 3.14 in the pcluster CLI.
| @functools.wraps(func) | ||
| async def wrapper(self, *args, **kwargs): | ||
| return await asyncio.get_event_loop().run_in_executor( | ||
| return await asyncio.get_running_loop().run_in_executor( |
There was a problem hiding this comment.
This only happens inside a running loop because it is awaiting so we don't need to create a new loop.
In Python 3.14, asyncio.get_event_loop() raises a RuntimeError when there is no running loop instead of implicitly creating one. Introduce an event_loop() context manager that reuses a running loop when present and otherwise creates a new loop and closes it on exit, avoiding leaked (unclosed) event loops. Use asyncio.get_running_loop() directly where already inside a running loop.
# Conflicts: # CHANGELOG.md
Description of changes
asyncio.get_event_loop()calls with a new utility function.In Python 3.14,
get_event_loop()raisesRuntimeErrorwhen no event loop is running instead of implicitly creating one.This is documented in Python official doc: https://docs.python.org/3.14/whatsnew/3.14.html#asyncio
Tests
References
Please review the guidelines for contributing and Pull Request Instructions.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.