Created
February 20, 2012 16:37
Revisions
-
igniteflow created this gist
Feb 20, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ import redis import time import sys def producer(): r = redis.Redis() i = 0 while True: r.rpush('queue', 'Message %d' % i) i += 1 time.sleep(1) def consumer(): r = redis.Redis() while True: val = r.blpop('queue') print 'Consuming: (%s, %s)' % val if __name__ == '__main__': """ Open up two terminals and run the two commands separately """ if sys.argv[1] == 'consumer': print "Starting consumer: " consumer() else: print "Starting producer: " producer()