title: ZeroMQ inter process communication from single thread loses messages
body: <p>I am currently exploring possibilities to test my zeromq applications. I was under the impression that I could just have a publisher/subscriber in the same thread, let the publisher publish and the subscriber subscribe to it without losing messages. Yet, when I let the publisher send a couple of messages, none gets through to the subscriber. </p>
  
  <p>Here is the code I use:</p>
  
  <pre><code>import zmq
  
  def main():
      ctx = zmq.Context.instance()
      sender = ctx.socket(zmq.PUB)
      sender.setsockopt(zmq.HWM, 1000)
      sender.bind('tcp://*:10001')
  
      rcvr = ctx.socket(zmq.SUB)
      rcvr.setsockopt(zmq.HWM, 1000)
      rcvr.connect('tcp://127.0.0.1:10001')
      rcvr.setsockopt(zmq.SUBSCRIBE, "")
  
      for i in range(100):
          sender.send('%i' % i)
  
      while True:
          try:
              print rcvr.recv(zmq.NOBLOCK)
          except zmq.ZMQError:
              break
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>When running this, I don't get any output.</p>
  
  <p>What strikes me is that the receiver is connected before the sender sends, and thus should be queuing those messages. Or is that an assumption that is plain wrong and I should use PUSH/PULL instead?</p>