Open
Conversation
Collaborator
|
@DonVito1982 thanks for your contribution, we will check it soon. |
There was a problem hiding this comment.
Pull Request Overview
This PR addresses the deprecation of asyncio.get_event_loop() in Python 3.12 by replacing it with the recommended asyncio.get_running_loop() method. The change also updates the error handling to match the different exception message format.
- Replaces deprecated
asyncio.get_event_loop()withasyncio.get_running_loop() - Updates error message detection to match the new exception format
binance/helpers.py
Outdated
| return loop | ||
| except RuntimeError as e: | ||
| if str(e).startswith("There is no current event loop in thread"): | ||
| if str(e).endswith("no running event loop"): |
There was a problem hiding this comment.
The error message check is too narrow and may miss valid RuntimeError cases. The exact error message from asyncio.get_running_loop() is 'no running event loop', but this check only matches strings ending with this phrase. Consider using a more precise check like str(e) == 'no running event loop' or check for the specific exception type.
Suggested change
| if str(e).endswith("no running event loop"): | |
| if str(e) == "no running event loop": |
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.
Addresses #1597
According to the asyncio eventloop documentation the
get_event_loop()was deprecated in version 3.12 and it recommends using theget_running_loop()method instead.Failure to find a
loopwithasyncio.get_running_loop()throws aRunTimeError. The expected error string was updated