-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker.py
60 lines (40 loc) · 1.58 KB
/
worker.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
54
55
56
from rna_distance import run_distance
from zeromq_rnadistance.worker import taskWorker
import sys
import zmq
reciever = 'tcp://localhost:5557'
sender = 'tcp://localhost:5558'
class rnaDistWorker(taskWorker):
def run(self):
while True:
data = self.receiver.recv_json()
ref = "this is %s" % data['ref']
struct_file = data['structure_file']
alignment_pair = data['alignment_pair']
print(alignment_pair)
structures = run_distance.read_structure_file(struct_file)
print(structures)
run_distance.run_distance_pexpect(ref, structures)
print('done')
def run_with_poll(self):
self.start_poll()
while True:
socks = dict(self.poller.poll(1000))
if socks:
if socks.get(self.receiver) == zmq.POLLIN:
print ("got message ")
data = self.receiver.recv_json(zmq.NOBLOCK)
ref = "this is %s" % data['ref']
struct_file = data['structure_file']
alignment_pair = data['alignment_pair']
print(alignment_pair)
structures = run_distance.read_structure_file(struct_file)
print(structures)
run_distance.run_distance_pexpect(ref, structures)
print('done')
else:
print('still watiing')
# Send results to sink
if __name__ == '__main__' :
worker = rnaDistWorker(reciever, sender)
worker.run_with_poll()