title: How to know if a ZeroMQ socket is ready?
body: <p>I have a simple <code>PUSH/PULL</code> ZeroMQ code in Python. It looks like below.</p>
  
  <pre><code>  def zmqtest(self):
  
       print('zmq')
       Process(target=start_consumer, args=('1', 9999)).start()
       Process(target=start_consumer, args=('2', 9999)).start()
  
       ctx = zmq.Context()
       socket = ctx.socket(zmq.PUSH)
       socket.bind('tcp://127.0.0.1:9999')
       # sleep(.5) # I have to wait here...
  
       for i in range(5):
          socket.send_unicode('{}'.format(i))
  </code></pre>
  
  <p>The problem is I have to wait more than <strong>.5</strong> second before sending message, otherwise only one consumer process can receive a message. If I wait more than .5 second, everything looks fine.</p>
  
  <p>I guess it takes a while before the socket binding to settle down, and it is done asynchronously.</p>
  
  <p>I wonder if there's a more reliable way to know when the socket is ready.</p>