blob: 519b3ea2a84797bbf34ad40b82a9767e2820d786 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import redis
import tasks
from json import loads, dumps
import socket
def run():
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].decode('utf-8'))
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])))
if __name__=="__main__":
run()
|