Repository: aio-libs-abandoned/aioredis-py

Issue:
socket_connect_timeout is not set in UnixDomainSocketConnection, leads to an error
On `2.0.0b1` version `UnixDomainSocketConnection` inherits from `Connection `, which has `disconnect` method https://github.com/aio-libs/aioredis-py/blob/master/aioredis/connection.py#L754, which relies on `socket_connect_timeout `, but this property is not set in `UnixDomainSocketConnection`, which leads to an error in my environment:
```
> File "/usr/local/lib/python3.8/site-packages/aioredis/connection.py", line 754, in disconnect
    async with async_timeout.timeout(self.socket_connect_timeout):
               │             │       │    └ <member 'socket_connect_timeout' of 'Connection' objects>
               │             │       └ UnixDomainSocketConnection<path=/tmp/tmpb312to6t/redis.socket,db=5>
               │             └ <class 'async_timeout.timeout'>
               └ <module 'async_timeout' from '/usr/local/lib/python3.8/site-packages/async_timeout/__init__.py'>

AttributeError: socket_connect_timeout
```
I am not sure how we should deal with it,  it seems that this method uses a different approach than the same method from `redis-py` (`socket_connect_timeout` is not used in `disconnect` in `redis-py` module).


Discussion:
Good catch! The class you are using, UnixDomainSocketConnection, overrides the constructor where we don't set the attribute socket_connect_timeout. In redis-py, UnixDomainSocketConnection also does not have this attribute, but technically: `self.socket_connect_timeout = socket_connect_timeout or socket_timeout` so in the UnixDomainSocketConnection class, we can add in our constructor `self.socket_time = self.socket_connect_timeout = socket_timeout`.

We might just need new input parameters though, like `socket_disconnect_timeout` since the redis-py implementation doesn't include a "timeout". @seandstewart @abrookins thoughts?
I'll check this out tomorrow!

Resolving patch:
diff --git a/aioredis/connection.py b/aioredis/connection.py
--- a/aioredis/connection.py
+++ b/aioredis/connection.py
@@ -1042,6 +1042,7 @@ def __init__(
         username: str = None,
         password: str = None,
         socket_timeout: float = None,
+        socket_connect_timeout: float = None,
         encoding: str = "utf-8",
         encoding_errors: str = "strict",
         decode_responses: bool = False,
@@ -1058,6 +1059,7 @@ def __init__(
         self.client_name = client_name
         self.password = password
         self.socket_timeout = socket_timeout
+        self.socket_connect_timeout = socket_connect_timeout or socket_timeout or None
         self.retry_on_timeout = retry_on_timeout
         self.health_check_interval = health_check_interval
         self.next_health_check = -1
@@ -1079,7 +1081,7 @@ def repr_pieces(self) -> Iterable[Tuple[str, Union[str, int]]]:
         return pieces
 
     async def _connect(self):
-        async with async_timeout.timeout(self.socket_timeout):
+        async with async_timeout.timeout(self.socket_connect_timeout):
             reader, writer = await asyncio.open_unix_connection(path=self.path)
         self._reader = reader
         self._writer = writer


Test patch:
diff --git a/tests/test_connection.py b/tests/test_connection.py
--- a/tests/test_connection.py
+++ b/tests/test_connection.py
@@ -3,6 +3,7 @@
 
 import pytest
 
+from aioredis.connection import UnixDomainSocketConnection
 from aioredis.exceptions import InvalidResponse
 from aioredis.utils import HIREDIS_AVAILABLE
 
@@ -19,3 +20,10 @@ async def test_invalid_response(r):
         with pytest.raises(InvalidResponse) as cm:
             await parser.read_response()
     assert str(cm.value) == "Protocol Error: %r" % raw
+
+
+@pytest.mark.asyncio
+async def test_socket_param_regression(r):
+    """A regression test for issue #1060"""
+    conn = UnixDomainSocketConnection()
+    await conn.disconnect() == True