Created
April 9, 2019 11:16
-
-
Save kristoff-it/8b7e91595fa740341615dabee3a22574 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis | |
r = redis.Redis(decode_responses=True) | |
data = {"hello": "world", "ans": 42} | |
p1 = r.pubsub(ignore_subscribe_messages=True) | |
p1.subscribe("channel") | |
# Assuming we have an exposed RESP3 parser from the library | |
r.publish("channel", redis.RESP3.to_string(data)) | |
reply = redis.RESP3.from_string(p1.get_message()['data']) | |
assert reply == data # => true | |
# Maybe also a bit more sugar? | |
resp_p1 = redis.RESP3.respify(p1) | |
r.RESP3.publish("channel", data) | |
reply1 = resp_p1.get_message() | |
assert reply1.data == data # => true | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment