zeromq/pyzmq — Issue #153: Zeromq hangs if connecting to invalid IPC socket
Author: carlopires
Created: 2011-10-29 17:01:00+00:00
State: open

import zmq

INVALID_ADDR = 'ipc:///tmp/idontexist.socket'

context = zmq.Context()
socket = context.socket(zmq.REQ)

socket.connect(INVALID_ADDR)
socket.send('hello')

poller = zmq.Poller()
poller.register(socket, zmq.POLLIN)
conn = dict(poller.poll(1000))
if conn:
if conn.get(socket) == zmq.POLLIN:
print "got result: ", socket.recv(zmq.NOBLOCK)
else:
print 'got no result'
print 'now, zeromq hangs, press CTRL_C to finish script :'('