-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask_dispatcher.py
53 lines (40 loc) · 1.42 KB
/
task_dispatcher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
l__author__ = 'Sandesh'
from celery import Celery
import logging as logger
from GeneralModules.file_open import *
from GeneralModules.Breaker8 import *
from GeneralModules.GeneDataStructure import *
import ujson
app = Celery('tasks', broker='redis://192.168.6.78:6379/0', backend='redis://192.168.6.78:6379/0')
# Set Depth
depth = 4
ret=[]
# open the file
file = file_open("input_smallest.txt")
# reading from the opened file
str_ = file.read().replace('\n', '')
input_list = breaker8(str_, 70)
break_length = len(input_list)
print(break_length)
# set up the dictionary
graph1 = {"nodes": [], "links": []}
CreateGeneDataStructure(graph1, depth)
def manage_analysis_task(in_list):
# for idx, word in enumerate(in_list):
# app.send_task('tasks.analysis', args=(word, graph1, 4, idx))
# analysis.delay(word, graph1, 4, idx)
# analysis(word, graph1, 4, idx)
async_result = []
for word in in_list:
async_result.append(app.send_task('tasks.analysis', args=(word, graph1, depth)))
for value in async_result:
ret.append(value.get())
print("DONE")
if __name__ == '__main__':
manage_analysis_task(input_list)
# Throw the graph at a JSON file
with open('output1-b.json', 'w') as outfile:
ujson.dump({"links": ret[len(ret)]['links'], "nodes": ret[len(ret)]['nodes']}, outfile)
#print(ret[0]['links'][5]['AC']['A'])
print(ret[12]['links'])
print("OVER")