def _ProcessCurlRequests(multi, requests):
  """cURL request processor.

  This generator yields a tuple once for every completed request, successful or
  not. The first value in the tuple is the handle, the second an error message
  or C{None} for successful requests.

  @type multi: C{pycurl.CurlMulti}
  @param multi: cURL multi object
  @type requests: sequence
  @param requests: cURL request handles

  """
  for curl in requests:
    multi.add_handle(curl)

  while True:
    (ret, active) = multi.perform()
    assert (pycurl.E_MULTI_OK, pycurl.E_CALL_MULTI_PERFORM) in ret

    if ret == pycurl.E_CALL_MULTI_PERFORM:
      # cURL wants to be called again
      continue

    while True:
      (remaining_messages, successful, failed) = multi.info_read()

      for curl in successful:
        multi.remove_handle(curl)
        yield (curl, None)

      for curl, errnum, errmsg in failed:
        multi.remove_handle(curl)
        yield (curl, "Error %s: %s" % (errnum, errmsg))

      if remaining_messages == 0:
        break

    if active == 0:
      # No active handles anymore
      break

    # Wait for I/O. The I/O timeout shouldn't be too long so that HTTP
    # timeouts, which are only evaluated in multi.perform, aren't
    # unnecessarily delayed.
    multi.select(1.0)
dataset/ETHPy150Open ganeti/ganeti/lib/http/client.py/_ProcessCurlRequests/swapped operands of `in`