eladm26
eladm26

Reputation: 563

in redis-py , is redis.StrictRedis.pipe thread safe?

short question.
I'm using redis-py to set some keys on my redis server and I'm experiencing some weird behaviour.
I suspect it has something to do with the StrictRedis.pipe. I have multiple threads pushing commands to the same pipe and after a while I run execute on this pipe and run all of its commands. I wanted to know if the pipe is thread-safe? can I push commands from multiple threads without any synchronisation mechanism?

Thank you.

Upvotes: 1

Views: 1374

Answers (1)

Arnaud Potier
Arnaud Potier

Reputation: 1780

Looks like it is not, according to the documentation:

"It is not safe to pass PubSub or Pipeline objects between threads."

Therefore I assume you either need some sort of synchronisation mechanism. I have to admit I haven't tested any, but if I were to implement one I would try to go with a Multithreaded queue.

There may be a better way to do it, as I am not a python expert.

Hope this helps, though

Upvotes: 1

Related Questions