Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pytest warning RuntimeError: Event loop is closed #11

Open
gertvdijk opened this issue Oct 10, 2023 · 0 comments
Open

Pytest warning RuntimeError: Event loop is closed #11

gertvdijk opened this issue Oct 10, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@gertvdijk
Copy link
Owner

Seen in Python 3.12 as warning, and printed on stderr on 3.11.5.

tests/integration/examples/test_append_header_ip.py::test_append_header_ip[start_testserver0]
  /home/gert/repos/purepythonmilter/.direnv/python-3.12/lib/python3.12/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in: <function StreamWriter.__del__ at 0x7fc2455c71a0>
  
  Traceback (most recent call last):
    File "/home/gert/.pyenv/versions/3.12.0/lib/python3.12/asyncio/streams.py", line 397, in __del__
      self.close()
    File "/home/gert/.pyenv/versions/3.12.0/lib/python3.12/asyncio/streams.py", line 343, in close
      return self._transport.close()
             ^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/gert/.pyenv/versions/3.12.0/lib/python3.12/asyncio/selector_events.py", line 1206, in close
      super().close()
    File "/home/gert/.pyenv/versions/3.12.0/lib/python3.12/asyncio/selector_events.py", line 871, in close
      self._loop.call_soon(self._call_connection_lost, None)
    File "/home/gert/.pyenv/versions/3.12.0/lib/python3.12/asyncio/base_events.py", line 772, in call_soon
      self._check_closed()
    File "/home/gert/.pyenv/versions/3.12.0/lib/python3.12/asyncio/base_events.py", line 519, in _check_closed
      raise RuntimeError('Event loop is closed')
  RuntimeError: Event loop is closed
  
    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
$ pytest -v -k test_server_protocol_violation_close_connection
[...]
tests/integration/test_server.py::test_server_protocol_violation_close_connection[start_testserver0] PASSEDException ignored in: <function StreamWriter.__del__ at 0x7f05a1d22200>
Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/streams.py", line 396, in __del__
    self.close()
  File "/usr/lib/python3.11/asyncio/streams.py", line 344, in close
    return self._transport.close()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 860, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "/usr/lib/python3.11/asyncio/base_events.py", line 761, in call_soon
    self._check_closed()
  File "/usr/lib/python3.11/asyncio/base_events.py", line 519, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
[...]

Unsure whether this is a test-only issue or an actual bug in real use cases too.

@gertvdijk gertvdijk added the bug Something isn't working label Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant