Skip to content

Instantly share code, notes, and snippets.

@batok
Created August 9, 2010 18:17
Show Gist options
  • Save batok/515843 to your computer and use it in GitHub Desktop.
Save batok/515843 to your computer and use it in GitHub Desktop.
import redis
import sys
import json
r = redis.Redis()
k = r.incr("nbb_key")
r.rpush("nbb_queue",k)
nk = "P{:010d}".format(k)
msg = ""
if len(sys.argv)>1:
msg = sys.argv[1]
msg = json.dumps(dict(request = "dummy", source = "test", user = "test", args = dict(msg = msg)))
r.set(nk, msg)
rk = "R"+nk[1:]
r.subscribe(rk)
result = ""
for x in r.listen():
if x and x.get("type") == "message":
result = x.get("data")
r.unsubscribe(x.get("channel"))
print result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment