Reputation: 23
I need to publish messages on one machine(setter) in specific channel and get it on other machines(handlers). The problem is that each handler should process unique message.
As I can see in documentation, there is no standard method to pop messages from channel, maybe I try to use it in wrong way?
Here is code of handler:
import redis
r=redis.Redis()
pubsub = r.pubsub()
pubsub.subscribe('test_channel')
for item in self.pubsub.listen():
...
Here is the code of setter:
import redis
r = redis.Redis()
r.publish('test_channel', 'test message')
Upvotes: 0
Views: 465
Reputation: 49932
Pub/Sub doesn't fit this pattern - look into using a List and call blocking pop operations in the handlers instead.
Upvotes: 2