Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import redis
  2.  
  3. r = redis.Redis(decode_responses=True)
  4.  
  5. data = {"hello": "world", "ans": 42}
  6.  
  7. p1 = r.pubsub(ignore_subscribe_messages=True)
  8. p1.subscribe("channel")
  9.  
  10. # Assuming we have an exposed RESP3 parser from the library
  11. r.publish("channel", redis.RESP3.to_string(data))
  12.  
  13. reply = redis.RESP3.from_string(p1.get_message()['data'])
  14. assert reply == data # => true
  15.  
  16. # Maybe also a bit more sugar?
  17. resp_p1 = redis.RESP3.respify(p1)
  18. r.RESP3.publish("channel", data)
  19. reply1 = resp_p1.get_message()
  20.  
  21. assert reply1.data == data # => true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement