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

Using watch within a pipline will use a different server_key if host/port are not provided #212

Closed
OlegZv opened this issue Jul 17, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@OlegZv
Copy link
Contributor

OlegZv commented Jul 17, 2023

Describe the bug
Using pipe.watch(key) within a pipeline with a client that was created without host or port the client inside the pipeline will use a different server. More generally, if Redis is trying to establish another connection (socket) with a server, it will get a connection to a new empty FakeRedis each time.

To Reproduce

from fakeredis import FakeRedis
fr = FakeRedis() 
fr.set("foo", "barr")
fr.set("boo", "bar")
with fr.pipeline() as pipe:
    keys_before_watch = set(fr.keys())
    pipe.watch("foo")
    assert set(fr.keys()) == keys_before_watch # Fails

Expected behavior
I expect FakeRedis to have the same data with and without a pipeline if I'm using the same instance of the FakeRedis.

Desktop (please complete the following information):

  • Ubuntu 22.04.2 LTC
  • python 3.10.12
  • redis-py version redis==4.6.0

Additional context
I wasn't sure if this is a bug really, because this can also be remediated by creating FakeRedis with some random values of host and port. The example above would work if you initialize fr with fr = FakeRedis(host='blah', port=0).
But to me, it seems more like a workaround, so I opened a PR.

@OlegZv OlegZv added the bug Something isn't working label Jul 17, 2023
@OlegZv
Copy link
Contributor Author

OlegZv commented Jul 17, 2023

This is related to #140 and #142. I believe as of #140 this was still working. After #142 a new connection from the connection pool would be created to a new/fresh FakeServer within the same pipeline.

@cunla cunla added triage Needs to be triaged and removed triage Needs to be triaged labels Jul 17, 2023
@cunla cunla closed this as completed Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants