I have to restructure a complex application and I would like to do this
with zeromq, I'm reading the doc and trying out things but I'm a bit
lost now, so some hints might be very useful..
The application I'm writing is very parallel, there are many
long-running processes that do things, managed by a central daemon.
I would like to be able to communicate with these processes to check the
current status, and interact with it, and these processes should write
the results on a common sink.
So it looks like the multiple worker with a sink might be the right
choice, but I also want to be able to communicate with every single
process separately.
Another thing which I'd like to do is to use Python Cmd class, and I
thought I could create a zmq class that behaves like a file, and thus be
passed in the Cmd object.
So I did the following, but apparently I just can't get it working,
because every time I receive I should acknoledge with a write and
vice-versa..
Do you think it's possible/makes sense to do something like this?
__metaclass__ = type
import zmq
ADDR = "tcp://127.0.0.1:5556"
context = zmq.Context()
class AsFile:
def __init__(self):
self.sock = None
def _read(self):
return self.sock.recv()
read = _read
readline = _read
def write(self, msg):
self.sock.send(msg)
class AsFileServer(AsFile):
def __init__(self):
super(AsFileServer, self).__init__()
self.sock = context.socket(zmq.REP)
self.sock.bind(ADDR)
class AsFileClient(AsFile):
def __init__(self):
super(AsFileClient, self).__init__()
self.sock = context.socket(zmq.REQ)
self.sock.connect(ADDR)
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev