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

Exception ignored in: <function AbstractConnection.__del__ at 0x107907240> #3239

Closed
chbndrhnns opened this issue May 21, 2024 · 3 comments · Fixed by #3438
Closed

Exception ignored in: <function AbstractConnection.__del__ at 0x107907240> #3239

chbndrhnns opened this issue May 21, 2024 · 3 comments · Fixed by #3438

Comments

@chbndrhnns
Copy link

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
@mgvalverde
Copy link

I also found this issue, in the meantime, downgrading to 4.6.0 solved the problem for me.

@cymux
Copy link

cymux commented Jun 19, 2024

on python3.11 this solved by downgrade to redis = "5.0.1" (from redis = "^5.0.4")

@teocns
Copy link

teocns commented Nov 5, 2024

atexit.register(__aredis.__del__)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants