This code will raise Resource temporarily unavailable when call with NOBLOCK:
context = zmq.Context()
sender = context.socket(zmq.PUSH)
sender.bind('tcp://*:15556')
sender.send('KeEpAliv', zmq.NOBLOCK) # this line will throw exception
#sender.send('KeEpAliv') # this line will ok
After read the docs, I found no hints for this. but docs for recv explained this flag.
Python wrappers raise
zmq.error.Again
if the underlying C API returnsEAGAIN
.Now, you should follow to zmq_send documentation, which states:
Also, in the errors section:
Now, why is it not possible to send any message? On the page describing PUSH/PULL sockets we can read the following about the
PUSH
socket:Before any peer connects to your socket, there's nowhere to send the messages, and there's no queue. Thus only 2 things are possible:
send()
in blocking mode, it blocks until a peer connectssend()
in non-blocking mode, it raiseszmq.error.Again
to inform you, that there's nothing that could be done with the message and you should try again later.Note, that you can also get this exception if queues for each of the connected peers are full (
PUSH
socket creates a separate queue for each connected peer).