[zeromq-dev] Designing a new architecture

andrea crotti andrea.crotti.0 at gmail.com
Thu Aug 2 18:50:32 CEST 2012

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
Do you think it's possible/makes sense to do something like this?

__metaclass__ = type

import zmq

ADDR = "tcp://"
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):

class AsFileServer(AsFile):
    def __init__(self):
        super(AsFileServer, self).__init__()
        self.sock = context.socket(zmq.REP)

class AsFileClient(AsFile):
    def __init__(self):
        super(AsFileClient, self).__init__()
        self.sock = context.socket(zmq.REQ)

More information about the zeromq-dev mailing list