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

Data persistence for sync and async clients is surprisingly different #297

Closed
steve-mavens opened this issue Mar 6, 2024 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@steve-mavens
Copy link

steve-mavens commented Mar 6, 2024

Describe the bug

The response to #293 states that separate fakeredis clients intentionally share state when the same connection parameters are used. However this is not consistent between sync and async clients.

To Reproduce

import asyncio

import fakeredis


async def amain():
    client_1 = fakeredis.FakeAsyncRedis()
    await client_1.set("async_key", "async_value")

    client_2 = fakeredis.FakeAsyncRedis()
    print(f"async_client/async_key {await client_2.get('async_key')}")


def main():
    client_1 = fakeredis.FakeRedis()
    client_1.set("sync_key", "sync_value")
    print(f"original client/sync_key {client_1.get('sync_key')}")

    client_2 = fakeredis.FakeRedis()
    print(f"sync client/async_key {client_2.get('async_key')}")
    print(f"sync client/sync_key {client_2.get('sync_key')}")


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(amain())
    main()

Results:

async_client/async_key b'async_value'
original client/sync_key b'sync_value'
sync client/async_key None
sync client/sync_key None

Expected behavior
"sync client/sync_key" expected to be sync_value to match async behaviour. Also I expected the sync and async clients to be drawing from the same shared state as each other, so I expected "sync client/async key" to be async_value.

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows 10
  • python version 3.8.16
  • redis-py version 5.0.2
  • full requirements.txt? fakeredis 2.21.1

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
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

1 participant