Skip to content

connection.can_read() raises OSError when connection is broken #2138

Closed
@kristjanvalur

Description

@kristjanvalur

Version: 4.2.2

Platform: Windows 11
Description:
redis.asyncio.connection.Connection(), the class provides a can_read method, which is used, for example, in Client.parse_response.

However, unlike Connection.read_response() there is no error handling present to turn any OSErrors into asyncio.ConnectionError.
And so, the OSError bubbles up and causes problems, where we expect only asyncio.ConnectionError to occur.
This plays havoc with retry-mechanisms and automatic reconnect.

The issue is evident when the connection to the redis server is interrupted during a blocking call to pubsub.run() where a get_message call is made with a positive timeout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions