Skip to content

Test failures with Python 3.14: RuntimeError: There is no current event loop in thread 'MainThread'.  #527

@sandrobonazzola

Description

@sandrobonazzola

Initially reported on https://bugzilla.redhat.com/show_bug.cgi?id=2327977

________________________ TestContextManager.test_sleeps ________________________

a = (<tests.test_asyncio.TestContextManager testMethod=test_sleeps>,), kw = {}

    @wraps(callable_)
    def wrapper(*a, **kw):
>       loop = asyncio.get_event_loop()

tests/test_asyncio.py:34: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7f38d5e1b0e0>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:681: RuntimeError
=========================== short test summary info ============================
FAILED tests/test_asyncio.py::TestAsync::test_attempt_number_is_correct_for_interleaved_coroutines
FAILED tests/test_asyncio.py::TestAsync::test_iscoroutinefunction - RuntimeEr...
FAILED tests/test_asyncio.py::TestAsync::test_retry - RuntimeError: There is ...
FAILED tests/test_asyncio.py::TestAsync::test_retry_using_async_retying - Run...
FAILED tests/test_asyncio.py::TestAsync::test_stop_after_attempt - RuntimeErr...
FAILED tests/test_asyncio.py::TestContextManager::test_async_retying_iterator
FAILED tests/test_asyncio.py::TestContextManager::test_do_max_attempts - Runt...
FAILED tests/test_asyncio.py::TestContextManager::test_reraise - RuntimeError...
FAILED tests/test_asyncio.py::TestContextManager::test_retry_with_result - Ru...
FAILED tests/test_asyncio.py::TestContextManager::test_sleeps - RuntimeError:...
================= 10 failed, 98 passed, 1 deselected in 2.42s ==================

According to https://docs.python.org/dev/whatsnew/3.14.html#id3

Removed implicit creation of event loop by asyncio.get_event_loop(). It now raises a RuntimeError if there is no current event loop. (Contributed by Kumar Aditya in gh-126353.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions