def Done(self, errmsg):
    """Finishes a request.

    @type errmsg: string or None
    @param errmsg: Error message if request failed

    """
    curl = self._curl
    req = self._req

    assert req.success is None, "Request has already been finalized"

    try:
      # LOCAL_* options added in pycurl 7.21.5
      from_str = "from %s:%s " % (
          curl.getinfo(pycurl.LOCAL_IP),
          curl.getinfo(pycurl.LOCAL_PORT)
      )
    except __HOLE__:
      from_str = ""
    logging.debug("Request %s%s finished, errmsg=%s", from_str, req, errmsg)

    req.success = not bool(errmsg)
    req.error = errmsg

    # Get HTTP response code
    req.resp_status_code = curl.getinfo(pycurl.RESPONSE_CODE)
    req.resp_body = self._resp_buffer_read()

    # Ensure no potentially large variables are referenced
    curl.setopt(pycurl.POSTFIELDS, "")
    curl.setopt(pycurl.WRITEFUNCTION, lambda _: None)

    if req.completion_cb:
      req.completion_cb(req)
dataset/ETHPy150Open ganeti/ganeti/lib/http/client.py/_PendingRequest.Done