configuration updates
This commit is contained in:
parent
94a34dc4df
commit
9c01b98542
|
@ -269,6 +269,14 @@ class Backend(threading.Thread):
|
||||||
self.subproc = None
|
self.subproc = None
|
||||||
self.backend = '%s/%s' % (os.getcwd(), 'rx.py')
|
self.backend = '%s/%s' % (os.getcwd(), 'rx.py')
|
||||||
|
|
||||||
|
self.q_watcher = queue_watcher(self.input_q, self.process_msg)
|
||||||
|
|
||||||
|
def publish(self, msg):
|
||||||
|
t = msg.type()
|
||||||
|
s = msg.to_string()
|
||||||
|
a = msg.arg1()
|
||||||
|
self.zmq_pub.send(json.dumps({'command': s, 'data': a, 'msgtype': t}))
|
||||||
|
|
||||||
def check_subproc(self): # return True if subprocess is active
|
def check_subproc(self): # return True if subprocess is active
|
||||||
if not self.subproc:
|
if not self.subproc:
|
||||||
return False
|
return False
|
||||||
|
@ -335,8 +343,12 @@ class Backend(threading.Thread):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while self.keep_running:
|
while self.keep_running:
|
||||||
msg = self.input_q.delete_head()
|
js = self.zmq_sub.recv()
|
||||||
self.process_msg(msg)
|
if not self.keep_running:
|
||||||
|
break
|
||||||
|
msg = gr.message().make_from_string(js, -4, 0, 0)
|
||||||
|
if not self.output_q.full_p():
|
||||||
|
self.output_q.insert_tail(msg)
|
||||||
|
|
||||||
class rx_options(object):
|
class rx_options(object):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
|
@ -389,6 +401,8 @@ def http_main():
|
||||||
|
|
||||||
my_backend = Backend(options, backend_input_q, backend_output_q)
|
my_backend = Backend(options, backend_input_q, backend_output_q)
|
||||||
server = http_server(input_q, output_q, options.endpoint)
|
server = http_server(input_q, output_q, options.endpoint)
|
||||||
|
q_watcher = queue_watcher(output_q, lambda msg : my_backend.publish(msg))
|
||||||
|
backend_q_watcher = queue_watcher(backend_output_q, lambda msg : process_qmsg(msg))
|
||||||
|
|
||||||
server.run()
|
server.run()
|
||||||
|
|
||||||
|
|
|
@ -233,22 +233,19 @@ class zeromq_terminal(threading.Thread):
|
||||||
self.zmq_pub.sndhwm = 5
|
self.zmq_pub.sndhwm = 5
|
||||||
self.zmq_pub.bind('tcp://*:%d' % port)
|
self.zmq_pub.bind('tcp://*:%d' % port)
|
||||||
|
|
||||||
self.queue_watcher = q_watcher(self.input_q, self.process_qmsg)
|
self.queue_watcher = q_watcher(self.input_q, lambda msg : self.zmq_pub.send(msg.to_string()))
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
def end_terminal(self):
|
def end_terminal(self):
|
||||||
self.keep_running = False
|
self.keep_running = False
|
||||||
|
|
||||||
def process_qmsg(self, msg):
|
|
||||||
msg = self.input_q.delete_head()
|
|
||||||
self.zmq_pub.send(msg.to_string())
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while self.keep_running:
|
while self.keep_running:
|
||||||
js = self.zmq_sub.recv()
|
js = self.zmq_sub.recv()
|
||||||
if not self.keep_running:
|
if not self.keep_running:
|
||||||
break
|
break
|
||||||
msg = gr.message().make_from_string(js, -4, 0, 0)
|
d = json.loads(js)
|
||||||
|
msg = gr.message().make_from_string(str(d['command']), d['msgtype'], d['data'], 0)
|
||||||
if self.output_q.full_p():
|
if self.output_q.full_p():
|
||||||
self.output_q.delete_head()
|
self.output_q.delete_head()
|
||||||
if not self.output_q.full_p():
|
if not self.output_q.full_p():
|
||||||
|
|
Loading…
Reference in New Issue