1

I have two redis-py clients that are accessing REDIS at the same time. Both clients are running infinite loops. Both clients are also looking at the same hash. The problem is that it seems when I start the continuous hgetall loop, I can no longer hset that value.

The first client is doing continuous hgetall

while True:
    query = r.hgetall('myHash')
    for result in query:
        #do something with value1, value2

The second client is doing continuous hset. If I remove the second client and just manually hset a new value, I still cannot set a new value.

r.hset('myHash', 'value1', '23')
r.hset('myHash', 'value2', '17')

Is this because REDIS is single threaded and the client that is hgetall never releases the thread to allow an hset?

NinjaKitty
  • 638
  • 7
  • 17
jaygrth
  • 31
  • 2
  • AFAIK, redis has its own queue that will run in order. You can have multiple clients connected to it, but it will run only 1 command at a time on its own side. What problems are you getting? – NinjaKitty Jul 11 '17 at 18:42
  • Can you run MONITOR against your Redis instance to see what commands are getting executed. – Tague Griffith Jul 11 '17 at 18:45

1 Answers1

0

Precisely, that is why you can't hset and hgetall on the same hash. Here is the official documentation about single threaded nature. Here is a related question explaining the same behavior. Further, if you are looking to implement parllelism on top of redis, here is a guide for that.

PseudoAj
  • 5,234
  • 2
  • 17
  • 37