Skip to content

Conversation

DonVito1982
Copy link

@DonVito1982 DonVito1982 commented Aug 3, 2025

Addresses #1597

According to the asyncio eventloop documentation the get_event_loop() was deprecated in version 3.12 and it recommends using the get_running_loop() method instead.

Failure to find a loop with asyncio.get_running_loop() throws a RunTimeError. The expected error string was updated

@pcriadoperez pcriadoperez self-assigned this Aug 3, 2025
@carlosmiei
Copy link
Collaborator

@DonVito1982 thanks for your contribution, we will check it soon.

@carlosmiei carlosmiei requested a review from Copilot August 4, 2025 13:39
Copy link

@Copilot Copilot AI left a 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() with asyncio.get_running_loop()
  • Updates error message detection to match the new exception format

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"):
Copy link

Copilot AI Aug 4, 2025

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.

Suggested change
if str(e).endswith("no running event loop"):
if str(e) == "no running event loop":

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants