redis-om-python
redis-om-python copied to clipboard
Thread/Coroutine Safety of Redis Connection
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 : https://github.com/redis/redis-py/issues/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:
- https://github.com/redis/redis-om-python/issues/527
- https://github.com/redis/redis-om-python/issues/519
This needs attention.