[zeromq-dev] zeromq is asynchronous?
andrea crotti
andrea.crotti.0 at gmail.com
Mon Aug 6 04:25:14 CEST 2012
Very good thanks now is more clear..
Anyway suppose a simple example of a long running process, which can be
simplified as
class Proc:
def __init__(self):
self.status = 0
def run(self):
while True:
self.status += 1
sleep(2)
Now suppose I want to be able to query the status of this process
from another process querying through zeromq sockets, what might be a
good way?
I thought about something like:
def start_proc_and_monitor():
pr = Proc()
thr = Monitor(pr)
print("starting the monitor thread")
thr.start()
pr.run()
def start_query():
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect(PORT)
if __name__ == '__main__':
pr1 = Process(target=start_proc_and_monitor)
pr2 = Process(target=start_query)
pr1.start()
pr2.start()
But in this way I need an extra thread, and pass the process itself to
the thread to make it possible to monitor it..
Better ways to do that?
More information about the zeromq-dev
mailing list