Exception ignored in: <function AbstractConnection.__del__ at 0x107907240> · Issue #3239 · redis/redis-py (original) (raw)
Version: 5.0.4
Platform: Python 3.12, mac OS
Description:
For every test that involves a redis client, I see the error "Exception ignored in: <function AbstractConnection.**del** at 0x107907240>" after the test run.
The test still passes but the warnings clutter the output a lot.
Is it possible to make the __del__
function not raise an exception in the case here?
Example code:
import pytest import redis
pool = redis.asyncio.ConnectionPool( host="localhost", port=6381, )
@pytest.fixture def anyio_backend(): return "asyncio"
@pytest.mark.anyio async def test_(): await pool.get_connection("doesnotmatter")
Test output:
test_.py::test_ PASSED [100%]
============================== 1 passed in 0.04s ===============================
Exception ignored in: <function AbstractConnection.__del__ at 0x1023bf2e0>
Traceback (most recent call last):
File "/Users/x/Library/Caches/pypoetry/virtualenvs/pyredis-anyio-SXcw3iV0-py3.12/lib/python3.12/site-packages/redis/asyncio/connection.py", line 216, in __del__
File "/Users/x/Library/Caches/pypoetry/virtualenvs/pyredis-anyio-SXcw3iV0-py3.12/lib/python3.12/site-packages/redis/asyncio/connection.py", line 223, in _close
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/streams.py", line 343, in close
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/selector_events.py", line 1206, in close
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/selector_events.py", line 871, in close
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 772, in call_soon
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 519, in _check_closed
RuntimeError: Event loop is closed
Process finished with exit code 0
Installed packages:
> pip freeze
anyio==4.3.0
idna==3.7
iniconfig==2.0.0
packaging==24.0
pluggy==1.5.0
pytest==8.2.1
redis==5.0.4
sniffio==1.3.1