Oliver Smith said the following on 8/24/2010 12:29 PM:
Abhishek K said the following on 8/24/2010 12:00 PM:
The method I was looking for was
class Extended_thread(Threading.thread):
def run(a)
#some logic
context=zmq.Context()
socket=context.socket(zmq.REP)
socket.bind('tcp://127.0.0.1:5555 <http://127.0.0.1:5555/>')
while True:
message=socket.recv()
new Extended_thread(socket)
Wait - that's creating a new thread for every message you receive.
That's going to be incredibly expensive.
What you actually need, apparently, is a zmq_device. I'm not sure how
you do that in Python.
Again, I think this is another example for the case where it should be
allowed to bind multiple times to an address over the same context, so
that multiple threads can service a single port, e.g.
ctx = zmq.Context(1)
workers = []
def createThreads(numThreads, endpoint):
global ctx, workers
for i in range(0, numThreads):
sock = ctx.socket(zmq.REP)
sock.bind(endpoint)
thread = new Extended_thread(sock)
workers.append(thread)
You can do this with a device, but if you're going to be doing it all
over a single context, it just seems like so much cpu wastage :)
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev