title: Is time.sleep() impacting the ZeroMQ poller.poll() response?
body: <p>I'm getting results I can't explain when making a ZeroMQ <strong><code>REQ/REP</code></strong> request with polling.</p>
  <p>The elapsed time, taken by the <code>poll()</code>-method, is influenced by a <code>time.sleep()</code> elsewhere in the code.</p>
  <p>I have a server process which runs a command, and returns the <code>pid</code> of the process. This is the request side code which has the issue:</p>
  <pre>
  import datetime, sys, time, zmq
  
  sleeptime = float(sys.argv[1])
  
  def log_msg(msg):
      print "{0}, {1}".format(datetime.datetime.utcnow().strftime('%Y%m%d_%H:%M:%S.%f'), msg)
  
  context = zmq.Context()
  socket = context.socket(zmq.REQ)
  socket.connect("tcp://{0}:{1}".format('myserver', 9980))
  poller = zmq.Poller()
  poller.register(socket, zmq.POLLIN)
  req = { 'req_type':'raw_cmd', 'cmd':'echo hello', 'block':0, 'timeout':300, 'return_output': 0}
  
  for i in range(4):
      time.sleep(sleeptime)
      socket.send_json(req)
      start = time.time()
      socks = dict((poller.poll(30000)))
      elapsed = (time.time()-start)*1000
      rep = socket.recv_json()
      log_msg('pid={0}, sleep={1}, time taken={2}'.format(rep['pid'], sleeptime, int(elapsed)))
  </pre>
  <p>The first poll elapsed time is quite variable, but all the subsequent ones take about 2 seconds less the sleep time, unless sleep time is 0, in which case it's fast, so:</p>
  <p><code>sleep = 0.5</code> :</p>
  <pre>
  20201008_08:27:24.168800, pid=52528, sleep=0.5, time taken=505
  20201008_08:27:26.210196, pid=52529, sleep=0.5, time taken=1540
  20201008_08:27:28.250891, pid=52530, sleep=0.5, time taken=1539
  20201008_08:27:30.295036, pid=52531, sleep=0.5, time taken=1543
  </pre>
  <p><code>sleep = 1.5</code> :</p>
  <pre>
  20201008_08:44:02.474492, pid=54730, sleep=1.5, time taken=295
  20201008_08:44:04.516844, pid=54731, sleep=1.5, time taken=540
  20201008_08:44:06.557980, pid=54732, sleep=1.5, time taken=539
  20201008_08:44:08.599717, pid=54733, sleep=1.5, time taken=539
  </pre>
  <p><code>sleep = 0</code> :</p>
  <pre>
  20201008_08:27:13.999147, pid=52513, sleep=0.0, time taken=690
  20201008_08:27:14.033915, pid=52514, sleep=0.0, time taken=34
  20201008_08:27:14.068803, pid=52515, sleep=0.0, time taken=34
  20201008_08:27:14.103947, pid=52516, sleep=0.0, time taken=34
  </pre>
  <p>So question is, why does the <code>time.sleep()</code> affect the time taken by the ZeroMQ <code>poller.poll()</code>?</p>