Skip to content

RediSearch: search command doesn't support asyncio Pipeline #2279

Closed
@alancleary

Description

@alancleary

The RediSearch search command returns an instance of the Result class except when the Redis client is a Pipeline because Pipeline returns itself instead of a result when you execute a command. There's code that checks for this in both the SearchCommands and AsyncSearchCommands classes:

if isinstance(res, Pipeline):

if isinstance(res, Pipeline):

However, this check doesn't work if the Pipeline is from the redis.asyncio.client module. The following modification should fix the issue:

from redis.client import Pipeline
from redis.asyncio.client import Pipeline as AsyncPipeline
...
        if isinstance(res, Pipeline) or isinstance(res, AsyncPipeline):
            return res
...

I'm not sure if it makes sense to check for both Pipeline types or if the SearchCommands class should check for just Pipeline and the AsyncSearchCommands class should check for just AsyncPipeline. Let me know and I can make a PR. Or feel free to make the changes yourself if that's easier. Thanks!

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