Do not install the requested event loop if it happens to match the existing one

This commit is contained in:
Adrián Chaves 2025-03-26 23:07:39 +01:00
parent 476234b07a
commit 7668a693e8
1 changed files with 4 additions and 2 deletions

View File

@ -131,8 +131,10 @@ def set_asyncio_event_loop(event_loop_path: str | None) -> AbstractEventLoop:
"""Sets and returns the event loop with specified import path."""
if event_loop_path is not None:
event_loop_class: type[AbstractEventLoop] = load_object(event_loop_path)
event_loop = event_loop_class()
asyncio.set_event_loop(event_loop)
event_loop = _get_asyncio_event_loop()
if not isinstance(event_loop, event_loop_class):
event_loop = event_loop_class()
asyncio.set_event_loop(event_loop)
else:
try:
with catch_warnings():