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

Seeking guidance for hiredis dependency on redis-py #3392

Closed
ramchandra-st opened this issue Sep 29, 2024 · 9 comments · Fixed by #3400
Closed

Seeking guidance for hiredis dependency on redis-py #3392

ramchandra-st opened this issue Sep 29, 2024 · 9 comments · Fixed by #3400
Assignees
Labels
bug Bug

Comments

@ramchandra-st
Copy link

I have a question regarding the hiredis dependency in redis-py.
Is hiredis a required dependency for using the package, or is it optional?

I have an implicit dependency on redis-py and I've encountered an issue with a locked version of hiredis in my requirements.txt

Since redis-py updates automatically as it is implicit, it can lead to a version mismatch where redis-py is updated, but hiredis remains locked to an older version, causing an unsynchronized state.

Could you provide guidance on how to handle this situation and avoid any conflicts arising from the version lock?

@ramchandra-st ramchandra-st changed the title Seeking guidance for hiredis dependency on reidis-py Seeking guidance for hiredis dependency on redis-py Sep 29, 2024
@ramchandra-st
Copy link
Author

ramchandra-st commented Sep 29, 2024

I noticed that in the recent redis-py update (5.1.0), the author forgot to mention the hiredis dependency, although it is mentioned here:

Including such a change in the release log would be quite helpful for other developers.

@ramchandra-st
Copy link
Author

So I request to add this information on release notes of 5.1.0 :)

@dmaier-redislabs
Copy link
Contributor

Hi @ramchandra-st,

it's possible to use redis-py without hiredis, but if hiredis is installed, then redis-py will use it. This is documented in the README here on Github.

Which version of hiredis are you using?

Regards,
David

@helissonomc
Copy link

Hey guys, i created this issue #3393 about it, i just realised that this is talking about this same issue, should i close it?

@dmaier-redislabs
Copy link
Contributor

@helissonomc Yes, please. Can you add any relevant detail here please.

@helissonomc
Copy link

helissonomc commented Sep 30, 2024

With version 5.1.0 I started to face the error message:
NameError: name 'hiredis' is not defined
The error was introduced by the code inside redis/utils.py

try:
    import hiredis  # noqa

    # Only support Hiredis >= 3.0:
    HIREDIS_AVAILABLE = int(hiredis.__version__.split(".")[0]) >= 3
    HIREDIS_PACK_AVAILABLE = hasattr(hiredis, "pack_command")
except ImportError:
    HIREDIS_AVAILABLE = False
    HIREDIS_PACK_AVAILABLE = False

If the hiredis version is lower than 3 (which mine is) the HIREDIS_AVAILABLE is going to be false, therefore it will keep giving error inside the redis/connection.py file, because the import hiredis will not be executed, but the code still relies on this import.

@ramchandra-st
Copy link
Author

ramchandra-st commented Oct 1, 2024

Yeah, problem presented by @helissonomc is same as what I want to highlight here.

Thanks folks for engagement here :)

@dmaier-redislabs
Copy link
Contributor

OK, seems to be a bug that was introduced by trying to enforce hiredis >=3. We will take a look and fix it. Thanks for the detailed report.

@dmaier-redislabs
Copy link
Contributor

dmaier-redislabs commented Oct 2, 2024

Hi,

this bug could be reproduced with redis-py 5.1.0 and hiredis-py 2.4.0. The library redis-py should fall back to its internal response parser if the hiredis-py has a lower version than 3.0. There are two boolean variables checked and HIREDIS_PACK_AVAILABLE can be true if any version of hiredis-py is installed, which causes the bug. This will be fixed in a maintenance version. We apologize for the inconvenience.

Regards,
David

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.

4 participants