AttributeError on `_lock` with Unix socket connection
soonum opened this issue · 1 comments
soonum commented
Describe the bug
I use aioredis to connect to a Redis instance via Unix socket. Since I've bumped to the version 2.0.1 of the lib I encounter an error.
This seems related to this commit. After digging a bit in the code, I've noticed that on UnixDomainSocketConnection
instantiation doesn't perform a super().__init__
nor refrence a self._lock
. Adding a self._lock = asyncio.Lock()
solves my issue.
If this is this the only thing to fix I could do a PR.
To Reproduce
import asyncio
import aioredis
client = aioredis.from_url("unix://@/a/path/to/redis.sock")
loop = asyncio.get_event_loop()
loop.run_until_complete(client.ping())
Expected behavior
A simple command such as ping
should pass.
Logs/tracebacks
Traceback (most recent call last):
File "/home/code/retrieve_cancel.py", line 60, in <module>
loop.run_until_complete(client.ping())
File "/home/code/python/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/code/python/lib/python3.9/site-packages/aioredis/client.py", line 1085, in execute_command
return await self.parse_response(conn, command_name, **options)
File "/home/code/python/lib/python3.9/site-packages/aioredis/client.py", line 1101, in parse_response
response = await connection.read_response()
File "/home/code/python/lib/python3.9/site-packages/aioredis/connection.py", line 898, in read_response
async with self._lock:
AttributeError: _lock
Python Version
Python 3.9.7
aioredis Version
Version: 2.0.1
Additional context
No response
Code of Conduct
- I agree to follow the aio-libs Code of Conduct
Andrew-Chen-Wang commented
Please create the necessary PR for this. I'm not sure if we test on Unix socket connection; if we don't, then a simple addition without a test case will do. Thank you!