code: def _DownloadReport(process_id, report_download_directory, customer_id,
                      report_definition):
    
    report_downloader = (googleads.adwords.AdWordsClient.LoadFromStorage()
                         .GetReportDownloader())
  
    filepath = os.path.join(report_download_directory,
                            'adgroup_%d.csv' % customer_id)
    retry_count = 0
  
    while True:
      print ('[%d/%d] Loading report for customer ID "%s" into "%s"...'
             % (process_id, retry_count, customer_id, filepath))
      try:
        with open(filepath, 'wb') as handler:
          report_downloader.DownloadReport(
              report_definition, output=handler,
              client_customer_id=customer_id)
        return (True, {'customerId': customer_id})
      except googleads.errors.AdWordsReportError as e:
        if e.code == 500 and retry_count < MAX_RETRIES:
          time.sleep(retry_count * BACKOFF_FACTOR)
        else:
          print ('Report failed for customer ID "%s" with code "%d" after "%d" '
                 'retries.' % (customer_id, e.code, retry_count+1))
          return (False, {'customerId': customer_id, 'code': e.code,
                          'message': e.message})
docs: Helper function used by ReportWorker to download customer report.
  
    Note that multiprocessing differs between Windows / Unix environments. A
    Process or its subclasses in Windows must be serializable with pickle, but
    that is not possible for AdWordsClient or ReportDownloader. This top-level
    function is used as a work-around for Windows support.
  
    Args:
      process_id: The PID of the process downloading the report.
      report_download_directory: A string indicating the directory where you
          would like to download the reports.
      customer_id: A str AdWords customer ID for which the report is being
          downloaded.
      report_definition: A dict containing the report definition to be used.
  
    Returns:
      A tuple indicating a boolean success/failure status, and dict request
      context.