SHARE
TWEET

Untitled

a guest Apr 19th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top