Skip to content

Retry on transient network errors in download_file (fixes Windows CI WinError 10054) - #302

Merged
martinpopel merged 2 commits into
masterfrom
copilot/fix-check-build-windows-39
Aug 19, 2026
Merged

martinpopel merged 2 commits into
masterfrom
copilot/fix-check-build-windows-39

Conversation

Copilot AI commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Windows CI was intermittently failing with WinError 10054 (connection forcibly reset by remote host) when downloading datasets from raw.githubusercontent.com, causing 4 tests to fail despite no code defect.

Changes

  • sacrebleu/utils.py — download_file: Wraps the urlopen call in a retry loop (3 attempts) with exponential backoff (2^attempt seconds) on OSError (which covers urllib.error.URLError and Windows socket errors). SSL errors still abort immediately.
for attempt in range(max_retries):
    try:
        with urllib.request.urlopen(source_path) as f, open(dest_path, 'wb') as out:
            out.write(f.read())
        break
    except ssl.SSLError:
        ...  # fatal, exit immediately
    except OSError as e:
        if attempt < max_retries - 1:
            sacrelogger.warning(f"Download attempt {attempt + 1} failed ({e}), retrying...")
            time.sleep(2 ** attempt)
        else:
            raise

…nt network errors

Co-authored-by: martinpopel <724617+martinpopel@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing GitHub Actions job check-build (windows-latest, 3.9) Retry on transient network errors in download_file (fixes Windows CI WinError 10054) Aug 19, 2026
Copilot AI requested a review from martinpopel August 19, 2026 10:55
@martinpopel
martinpopel marked this pull request as ready for review August 19, 2026 20:29
@martinpopel
martinpopel merged commit b07d346 into master Aug 19, 2026
31 checks passed
@martinpopel
martinpopel deleted the copilot/fix-check-build-windows-39 branch August 19, 2026 20:30

This branch was successfully deployed

1 active deployment
release — dfeeefee Deployed Aug 19, 2026 by Copilot via Build and publish Python distributions to PyPI #47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants