-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Address deprecation #1598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Address deprecation #1598
Conversation
|
@DonVito1982 thanks for your contribution, we will check it soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"): |
Copilot
AI
Aug 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| if str(e).endswith("no running event loop"): | |
| if str(e) == "no running event loop": |
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