Skip to content

Instantly share code, notes, and snippets.

@wraithan
Created April 11, 2012 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wraithan/2360601 to your computer and use it in GitHub Desktop.
Save wraithan/2360601 to your computer and use it in GitHub Desktop.
Shows that messages are queued.
import redis
client = redis.StrictRedis()
pubsub = client.pubsub()
pubsub.subscribe('in')
# in redis: 1334163648.749540 "SUBSCRIBE" "in"
client2 = redis.StrictRedis()
client2.publish('in', 'meh1')
# in redis: 1334163693.949203 "PUBLISH" "in" "meh1"
client2.publish('in', 'meh2')
# in redis: 1334163697.516875 "PUBLISH" "in" "meh2"
for message in pubsub.listen():
print(message)
# {'pattern': None, 'type': 'message', 'channel': 'in', 'data': 'meh1'}
# {'pattern': None, 'type': 'message', 'channel': 'in', 'data': 'meh2'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment