Loading client/redis_rpc_client.py +15 −4 Original line number Diff line number Diff line Loading @@ -7,8 +7,12 @@ import json import redis import sys import uuid from redis.exceptions import ConnectionError class RedisRPCClient(object): def __init__(self, host, port, db, rpcQueue): Loading @@ -18,8 +22,15 @@ class RedisRPCClient(object): def call(self, request): requestId = uuid.uuid1().hex request["req_id"] = requestId try: self.client.lpush(self.rpcQueue, json.dumps(request)) channel, response = self.client.brpop(requestId, timeout = 30) except ConnectionError: sys.exit("\nFATAL: unable to establish a connection with the message broker (Redis).\n") except TypeError: sys.exit("""\nFATAL: no response received.\n Please check if the message broker (Redis) and the database (PostgreSQL) are up and running.\n""") else: response = json.loads(response.decode("utf-8")) return response Loading Loading
client/redis_rpc_client.py +15 −4 Original line number Diff line number Diff line Loading @@ -7,8 +7,12 @@ import json import redis import sys import uuid from redis.exceptions import ConnectionError class RedisRPCClient(object): def __init__(self, host, port, db, rpcQueue): Loading @@ -18,8 +22,15 @@ class RedisRPCClient(object): def call(self, request): requestId = uuid.uuid1().hex request["req_id"] = requestId try: self.client.lpush(self.rpcQueue, json.dumps(request)) channel, response = self.client.brpop(requestId, timeout = 30) except ConnectionError: sys.exit("\nFATAL: unable to establish a connection with the message broker (Redis).\n") except TypeError: sys.exit("""\nFATAL: no response received.\n Please check if the message broker (Redis) and the database (PostgreSQL) are up and running.\n""") else: response = json.loads(response.decode("utf-8")) return response Loading