Re: [zeromq-dev] Why socket.send will block without consumer
On Wednesday, March 20, 2013 12:14:09 PM He Jie Xu wrote: Hi, all I try zeromq with following code: import zmq import random import time context = zmq.Context() socket = context.socket(zmq.PUSH) socket.bind(ipc://test.sock) socket.setsockopt(zmq.HWM, 1000) while True: zipcode = random.randrange(1, 10) temperature = random.randrange(1, 215) message = %d %d % (zipcode, temperature) socket.send(message) print 'send', message time.sleep(1) When I am running the code without any consumer. it will block at 'socket.send' But after I read the document, I think when I set HWM, the message will send to memory buffer, it shouldn't block. Is there any wrong? How can I make the 'socket.send' won't block? my zmq version was 2.1.11 I will appreciate any help from you! This is one of the non-obvious aspects of zmq. Queues only exist when there are known connections (whether potential or established). For sockets that connect, the connections are known as you specify them. For sockets that bind, the connections are known only when they are received. Therefore, a bind socket that has no peers (no known connections) will block when you try to send. It's a little confusing because a connect socket that no peers will not block, meaning that the choice to bind or connect produces different behaviors. But it makes sense once you understand how the queues work. Justin___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
[zeromq-dev] Why socket.send will block without consumer
Hi, all I try zeromq with following code: import zmq import random import time context = zmq.Context() socket = context.socket(zmq.PUSH) socket.bind(ipc://test.sock) socket.setsockopt(zmq.HWM, 1000) while True: zipcode = random.randrange(1, 10) temperature = random.randrange(1, 215) message = %d %d % (zipcode, temperature) socket.send(message) print 'send', message time.sleep(1) When I am running the code without any consumer. it will block at 'socket.send' But after I read the document, I think when I set HWM, the message will send to memory buffer, it shouldn't block. Is there any wrong? How can I make the 'socket.send' won't block? my zmq version was 2.1.11 I will appreciate any help from you! Thanks you. ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Re: [zeromq-dev] Why socket.send will block without consumer
Hi, The HWM is a maximum buffer length (not actually identical). For PUSH, send will block if it reach the HWM. Thanks Min On Wednesday, March 20, 2013, He Jie Xu wrote: Hi, all I try zeromq with following code: import zmq import random import time context = zmq.Context() socket = context.socket(zmq.PUSH) socket.bind(ipc://test.sock) socket.setsockopt(zmq.HWM, 1000) while True: zipcode = random.randrange(1, 10) temperature = random.randrange(1, 215) message = %d %d % (zipcode, temperature) socket.send(message) print 'send', message time.sleep(1) When I am running the code without any consumer. it will block at 'socket.send' But after I read the document, I think when I set HWM, the message will send to memory buffer, it shouldn't block. Is there any wrong? How can I make the 'socket.send' won't block? my zmq version was 2.1.11 I will appreciate any help from you! Thanks you. ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev