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

Thread/Coroutine Safety of Redis Connection #552

Open
bearrito opened this issue Aug 8, 2023 · 0 comments
Open

Thread/Coroutine Safety of Redis Connection #552

bearrito opened this issue Aug 8, 2023 · 0 comments

Comments

@bearrito
Copy link

bearrito commented Aug 8, 2023

Concerning https://github.com/redis/redis-om-python/blob/main/docs/connections.md#connection-objects

Module level imports and creation of redis clients might not be co-routine safe : redis/redis-py#2835

Is it possible to augment providing a redis connection directly, and instead provide a function?

So we might end up with

def redis_provider(...) -> redis.Redis:
...


class Customer(HashModel):
    first_name: str
    last_name: str
    age: int

    class Meta:
        database_provider = redis_provider

Another use of this would be able to combine with https://github.com/testcontainers/testcontainers-python.

Test containers set a unique/random port per test invocation, so there is no way to configure a module level import

Related:

  1. Testing of code with asyncio version of redis-om can't be done #527
  2. Set RedisModel.Meta.database at runtime, not import time #519
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant