For example, getting a value:
|
result = self._backend.get(key) |
Goes to the backend:
|
value = self._rd.get(self.add_prefix(key)) |
And there it uses the global Redis connection (self._rd) without locking it.
Which probably relates to this setting in Redis client
https://github.com/redis/redis-py/blob/master/redis/client.py#L271 and then the code fails on the retries when one thread closes the connection and the other tries to use it around here https://github.com/redis/redis-py/blob/master/redis/client.py#L638
Unfortunately I no longer have the stack traces in the slack history. We ended up always using a single-threaded WSGI runner.
I think the correct way is to lock the backend before using it, I have not checked the thread-safety guarantees by RedisPy.