XX-net/XX-Net · warning

download %s to %s fail:%r

Error message

download %s to %s fail:%r

What it means

Wrapped exception from a single download attempt inside download_file's retry loop; the exception object is included via %r. The loop then retries; only exhaustion of retries surfaces as a hard failure to the caller.

Source

Thrown at code/default/gae_proxy/local/download_gae_lib.py:95

                        if not chunk_len:
                            break

                        chunk = req.read(chunk_len)
                        if not chunk:
                            break
                        fp.write(chunk)
                        downloaded += len(chunk)
                        left -= len(chunk)

            if downloaded != file_size:
                xlog.warn("download size:%d, need size:%d, download fail.", downloaded, file_size)
                os.remove(filename)
                continue
            else:
                xlog.info("download %s to %s success.", org_url, filename)
                return True
        except Exception as e:
            xlog.warn("download %s to %s fail:%r", org_url, filename, e)
            continue
    xlog.warn("download %s fail", org_url)


def download_unzip(url, extract_path):
    if os.path.isdir(extract_path):
        return True

    data_root = os.path.join(top_path, 'data')
    download_path = os.path.join(data_root, 'downloads')
    if not os.path.isdir(download_path):
        os.mkdir(download_path)

    fn = url.split("/")[-1]
    dfn = os.path.join(download_path, fn)

    if not download_file(url, dfn):
        xlog.warn("download file %s fail.", url)

View on GitHub (pinned to cfa5bc17b6)

Solutions

  1. Read the %r exception detail to identify the root cause (DNS/TLS/timeout/disk)
  2. Test connectivity to the download host directly (curl the same URL)
  3. Free up disk space / fix permissions in the download directory
  4. If persistent, download the archive manually and extract it to the expected path
Defensive patterns

Strategy: retry

Try / catch

try:
    download_file(url, fn)
except Exception as e:
    log.warning('download failed: %r', e)  # already retried internally; backoff and retry later

Prevention

When it happens

Trigger: Any exception during urlopen/read/write of one attempt: DNS failure, TLS error, timeout, disk write error, connection reset by the GAE front IP.

Common situations: No internet, firewall blocking Google IPs, TLS interception, read-only or full disk for the temp file, IPv6 issues.

Related errors


AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27). Data as JSON: /api/errors/828576d3a0060a5e. Report an issue: GitHub.