Skip to content

Commit

Permalink
Adding try/catch around connection to redis, add a little extra verbo…
Browse files Browse the repository at this point in the history
…se messaging
  • Loading branch information
pete0emerson committed Jan 23, 2012
1 parent 1c09a92 commit 3872145
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 9 additions & 1 deletion receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
import zmq
import json
import argparse
import sys

parser = argparse.ArgumentParser()
parser.add_argument('--verbose', dest='verbose', action='store_true', help='Turn on verbose mode')
args = parser.parse_args()

r = redis.Redis("localhost")
try:
r = redis.Redis("localhost")
r.get('connected')
except:
print "Not connected to the redis server."
sys.exit(1)

context = zmq.Context()
socket = context.socket(zmq.PULL)
Expand All @@ -27,5 +33,7 @@
if args.verbose:
print 'Storing key ' + key + ' ==> ' + message
r.set(key, message)
if args.verbose:
print 'Appending "' + host + '" to "job_done:' + str(job_id) + '"'
key = 'job_done:' + str(job_id)
r.rpush(key, host)
8 changes: 7 additions & 1 deletion transmitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
import zmq
import pprint
import argparse
import sys

parser = argparse.ArgumentParser()
parser.add_argument('--verbose', dest='verbose', action='store_true', help='Turn on verbose mode')
args = parser.parse_args()

r = redis.Redis("localhost")
try:
r = redis.Redis("localhost")
r.get('connected')
except:
print "No connection to the redis server."
sys.exit(1)

while True:
if args.verbose:
Expand Down

0 comments on commit 3872145

Please sign in to comment.