aboutsummaryrefslogtreecommitdiffstats
path: root/python/client.py
blob: 177ab1ed3b81163cb7f58d0d5c1dbc290b2ccb21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import redis
import tasks
from pickle import loads, dumps
import socket

hostname = socket.gethostname()
if hostname == 'debian':
    q = redis.Redis(unix_socket_path='/var/run/redis/redis.sock')
elif hostname == 'gomez':
    q = redis.Redis(host='debian')

while True:
    f, args = loads(q.blpop("tasks")[1])
    getattr(tasks, f)(*args)
    if f == "build_portfolio":
        q.rpush("tasks",  dumps(("build_scenarios", args)))
    if f == "build_scenarios":
        q.rpush("tasks", dumps(("generate_scenarios", args[:-1])))