Skip to content

RuntimeError: Event loop is closed #178

Closed
@dimaqq

Description

@dimaqq

After upgrading to pytest==5.4.3 pytest-asyncio==0.14.0 I'm getting transient(?) test failures and all I see in the log is this:

=================================== FAILURES ===================================
___________________________ test_xx ___________________________

kwargs = {'xx': XxFixture(, ...}
 
    @functools.wraps(func)
    def inner(**kwargs):
>       coro = func(**kwargs)
 
/root/.cache/pypoetry/virtualenvs/xx-py3.8/lib/python3.8/site-packages/pytest_asyncio/plugin.py:175: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/root/.cache/pypoetry/virtualenvs/xx-py3.8/lib/python3.8/site-packages/pytest_asyncio/plugin.py:175: in inner
    coro = func(**kwargs)
/root/.cache/pypoetry/virtualenvs/xx-py3.8/lib/python3.8/site-packages/pytest_asyncio/plugin.py:177: in inner
    task = asyncio.ensure_future(coro, loop=_loop)
/usr/local/lib/python3.8/asyncio/tasks.py:661: in ensure_future
    task = loop.create_task(coro_or_future)
/usr/local/lib/python3.8/asyncio/base_events.py:429: in create_task
    self._check_closed()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_UnixSelectorEventLoop running=False closed=True debug=False>

    def _check_closed(self):
        if self._closed:
>           raise RuntimeError('Event loop is closed')
E           RuntimeError: Event loop is closed

/usr/local/lib/python3.8/asyncio/base_events.py:508: RuntimeError
---------------------------- Captured stdout setup -----------------------------

There are some fragile tests in the project and we use flaky to manage those, so I see this error only when some test fails thrice.
Weirdly I don't get to see the actual test failure/cause in this case.

At the moment I'm at a loss as to how to debug it 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions