diff options
Diffstat (limited to 'python/client.py')
| -rw-r--r-- | python/client.py | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/python/client.py b/python/client.py deleted file mode 100644 index d68334c1..00000000 --- a/python/client.py +++ /dev/null @@ -1,38 +0,0 @@ -import logging -import sys - -from utils.db import dbconn -from common import get_redis_queue -from subprocess import CalledProcessError -from tasks import Rpc - -def run(): - ET = dbconn('etdb') - q = get_redis_queue() - while True: - rpc = Rpc.from_json(q.blpop("tasks")[1].decode('utf-8')) - - if rpc.fun == 'generate_scenarios': - rpc.args += [ET] - logger.info("running: {}, {}".format(rpc.fun, rpc.args)) - try: - rpc() - except CalledProcessError: - logger.error("'{}' did not complete".format(rpc.fun)) - else: - logger.info("'{}' completed".format(rpc.fun)) - if rpc.fun == "build_portfolios": - q.rpush("tasks", str(Rpc("build_scenarios", rpc.args))) - if rpc.fun == "build_scenarios": - q.rpush("tasks", str(Rpc("generate_scenarios", rpc.args[:-1]))) - ET.close() - -if __name__=="__main__": - logger = logging.getLogger('intex') - formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') - logger.setLevel(logging.INFO) - # log to stderr, which is intercepted by circus - sh = logging.StreamHandler(sys.stdout) - sh.setFormatter(formatter) - logger.addHandler(sh) - run() |
