Skip to content

Conversation

@befeleme
Copy link

This probably resolves #28
Discl: my understanding of asyncio is very limited, there may be a better way of solving this.

@kwarunek kwarunek requested a review from Copilot July 21, 2025 14:34
Copy link

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 a compatibility issue with Python 3.14 where asyncio.get_event_loop() no longer automatically creates a new event loop. The change updates the code to explicitly create new event loops using asyncio.new_event_loop() instead.

  • Replaces asyncio.get_event_loop() with asyncio.new_event_loop() in test cases and documentation
  • Ensures compatibility with Python 3.14's stricter event loop management

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/test_asynctestcase_get_event_loop.py Updates test case to use asyncio.new_event_loop()
aiounittest/case.py Updates documentation example to use asyncio.new_event_loop()

def get_event_loop(self):
self.my_loop = asyncio.get_event_loop()
self.my_loop = asyncio.new_event_loop()
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When creating a new event loop with asyncio.new_event_loop(), it's recommended to also set it as the current event loop using asyncio.set_event_loop(self.my_loop) to ensure proper context for asyncio operations.

Suggested change
self.my_loop = asyncio.new_event_loop()
self.my_loop = asyncio.new_event_loop()
asyncio.set_event_loop(self.my_loop)

Copilot uses AI. Check for mistakes.

def get_event_loop(self):
self.my_loop = asyncio.get_event_loop()
self.my_loop = asyncio.new_event_loop()
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When creating a new event loop with asyncio.new_event_loop(), it's recommended to also set it as the current event loop using asyncio.set_event_loop(self.my_loop) to ensure proper context for asyncio operations.

Suggested change
self.my_loop = asyncio.new_event_loop()
self.my_loop = asyncio.new_event_loop()
asyncio.set_event_loop(self.my_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.

Python 3.14: removed implicit loop creation with get_event_loop

1 participant