Skip to content

AttributeError in UnixDomainSocketConnection starting v4.1.0 #1902

@levincarmel

Description

@levincarmel

Version: v4.1.0

Platform: python 3.9

Description:
I have a ConnectionPool with connection_class=UnixDomainSocketConnection.
In order to verify the socket is unreachable, we send a ping command and expect to get a ConnectionError, but starting v4.1.0 we get an AttributeError instead.

connection_pool = ConnectionPool(
                connection_class=redis.connection.UnixDomainSocketConnection, 
                max_connections = None,
                path=socket_path, 
                "password": password,
                "socket_timeout": socket_timeout,
                "encoding": "utf-8",
                "encoding_errors": "strict",
                "decode_responses": True,
                "retry_on_timeout": False,
)
rc = redis.Redis(connection_pool=connection_pool)

Then I terminate the process that is responsible for the above socket, and do: rc.ping() in order to know the socket is unreachable, from which I expect to get a ConnectionError (this is what we got from the ping in earlier versions).
But instead, in v4.1.0 (and v4.1.1) I get: AttributeError: 'UnixDomainSocketConnection' object has no attribute 'host'.

I investigated a little and seems like changing the socket.error to OSError in connections.py caused ConnectionResetError to get caught by an earlier except clause, where self.host is printed (and of course UnixDomainSocketConnection doesn't have one).
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions