fix: replace deprecated asyncio.get_event_loop() with modern approach
#1865
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.
Replace deprecated
get_event_loop()withget_running_loop()and fallback tonew_event_loop()to fix the "no current event loop" warning in Python 3.10+ #1824Description
This PR updates the event loop handling in the test suite by replacing the deprecated
asyncio.get_event_loop()with the modern approach usingget_running_loop()with a fallback tonew_event_loop(). The change specifically targets the code in/tortoise/contrib/test/__init__.py.Motivation and Context
Since Python 3.10, using
asyncio.get_event_loop()triggers a deprecation warning:DeprecationWarning: There is no current event loopThis change modernizes the code to use the recommended approach for handling event loops, eliminating the deprecation warning while maintaining functionality.
How Has This Been Tested?
Running tests
Checklist: