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

AttributeError in UnixDomainSocketConnection starting v4.1.0 #1902

Closed
levincarmel opened this issue Jan 26, 2022 · 0 comments · Fixed by #1903
Closed

AttributeError in UnixDomainSocketConnection starting v4.1.0 #1902

levincarmel opened this issue Jan 26, 2022 · 0 comments · Fixed by #1903
Labels
bug Bug

Comments

@levincarmel
Copy link

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!

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

Successfully merging a pull request may close this issue.

2 participants