diff options
author | Chayim <chayim@users.noreply.github.com> | 2023-03-22 18:04:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-22 18:04:42 +0200 |
commit | 7b48b1bb34f97e4adf32c12a987ff593dc536aef (patch) | |
tree | 779459c3c1472e29f8e639877759d80dbed9b917 /tests/test_asyncio/test_connection.py | |
parent | 54a1dce8cbe5b7082588e831e0db22f2aa6a5166 (diff) | |
download | redis-py-4.3.tar.gz |
Diffstat (limited to 'tests/test_asyncio/test_connection.py')
-rw-r--r-- | tests/test_asyncio/test_connection.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_asyncio/test_connection.py b/tests/test_asyncio/test_connection.py index f6259ad..c414ee0 100644 --- a/tests/test_asyncio/test_connection.py +++ b/tests/test_asyncio/test_connection.py @@ -28,6 +28,29 @@ async def test_invalid_response(create_redis): assert str(cm.value) == f"Protocol Error: {raw!r}" +@pytest.mark.onlynoncluster +async def test_asynckills(): + from redis.asyncio.client import Redis + + for b in [True, False]: + r = Redis(single_connection_client=b) + + await r.set("foo", "foo") + await r.set("bar", "bar") + + t = asyncio.create_task(r.get("foo")) + await asyncio.sleep(1) + t.cancel() + try: + await t + except asyncio.CancelledError: + pytest.fail("connection left open with unread response") + + assert await r.get("bar") == b"bar" + assert await r.ping() + assert await r.get("foo") == b"foo" + + @skip_if_server_version_lt("4.0.0") @pytest.mark.redismod @pytest.mark.onlynoncluster |