The ZMQ_PUSH
section in ZMQ socket documentation say that calling send()
on PUSH socket, which has no downstream nodes should block until at least one node becomes available.
However, running the following code does not seem to block on send()
. Also, the process does not exit until I run a matching PULL socket and receive the messages:
import zmq
import time
zmq_context = zmq.Context()
print '> Creating a PUSH socket'
sender = zmq_context.socket(zmq.PUSH)
print '> Connecting'
sender.connect('tcp://localhost:%s' % 5555)
print '> Sending'
sender.send('message 1')
print '> Sent'
Output:
Creating a PUSH socket
Connecting
Sending
Sent
Am I missing something, or is this a bug in PyZmq?
Version Info: Windows 7, Python 2.7, PyZMQ 14.0.1
EDIT
After some fiddling, it seems that if I replace sender.connect('tcp://localhost:5555)
with sender.bind('tcp://127.0.0.1:5555)
, it works as expected. Not sure how its related, though.