Skip to content

fix(examples): retry the Wireshark sample downloads on 429, 5xx and timeouts (#1658) - #1659

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1658-sample-download-retry
Oct 13, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1658-sample-download-retry

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

Please follow the guide below

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • release — bumps the version or rolls up a distribution
  • chore — anything else

Description of your pull request and other information

_download (examples/generators/pcapng.py:876) now retries HTTP 429, 5xx and timeouts: 3 attempts, 2 s backoff doubling, or the Retry-After header (seconds or HTTP-date), with at most 30 s of waiting per download. A Retry-After past that budget ends the retries rather than being cut short. Other 4xx and unreachable hosts still fail at once, so an offline run is as quick as before. Each retry is logged on stderr; the SHA-256 check and the stand-in fallback are unchanged. Only the waiting is bounded: urlopen's 30 s timeout applies per socket operation, not per attempt.

New tests/project/test_pcapng_download_retry_1658_unit.py stubs urlopen and the clock: 429 then success, Retry-After in both forms, the budget and its inclusive edge, 404 not retried, 500 and 599 retried, exhausted retries falling back to the stand-in. The -0000 date test pins TZ=America/New_York, since on a UTC host the bug it guards cannot show. All 8 fail against the old generator. The 404 test fails there only on its 429, 5xx and timeout control rows, since the old code retried nothing. Also green: tests/test_support_helpers.py, tests/project/test_generators_import_their_own_tree.py, test_isort_clean.py.

Closes #1658

…imeouts (#1658)

- _download made one attempt, so an HTTP 429 on 9df91d4 sent Integration
  Python 3.11 straight to the offline stand-in. HTTP 429, 5xx and timeouts
  are now retried: 3 attempts, 2 s backoff doubling, or the Retry-After
  header (seconds or HTTP-date), with at most 30 s of waiting per download.
  A Retry-After past that budget ends the retries instead of being cut short.
- Other 4xx and unreachable hosts still fail at once. Each retry is logged on
  stderr. The SHA-256 check and the stand-in fallback are unchanged.

New tests/project/test_pcapng_download_retry_1658_unit.py stubs urlopen and
the clock: 429 then success, Retry-After in both forms, the budget and its
inclusive edge, 404 not retried, 500 and 599 retried, and exhausted retries
falling back to the stand-in. The -0000 date test pins TZ off UTC. All 8
fail against the old generator; 8 pass with the fix.

Closes #1658
@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Oct 13, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at 26c618114. Sonnet cross-review, two rounds. In round 1 the -0000 Retry-After row only failed off UTC, which CI never runs, and two boundary mutants survived. Round 2 pins TZ=America/New_York and restores it, and adds rows for a wait of exactly the 30 s budget and for 500 and 599. All three mutants now die. I re-ran the new test under TZ=UTC and test_support_helpers.py: 8 and 37 OK.

@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 89.66% (unit tier, Python 3.14, 26c618114, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 3 20 3 95.16%
pcapkit/const 18858 954 2366 868 91.06%
pcapkit/corekit 2366 67 760 35 96.48%
pcapkit/dumpkit 275 3 100 3 98.40%
pcapkit/foundation 2884 145 1010 35 94.14%
pcapkit/interface 138 7 52 5 93.68%
pcapkit/protocols 17166 226 4580 191 98.06%
pcapkit/toolkit 1036 168 386 5 82.35%
pcapkit/utilities 494 4 146 4 98.75%
pcapkit/vendor 4409 2342 1006 157 43.25%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit c338013 into main Oct 13, 2026
38 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 13, 2026
@JarryShaw
JarryShaw deleted the fix/1658-sample-download-retry branch October 13, 2026 16:10
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(examples): retry the Wireshark sample downloads on HTTP 429 before falling back to the stand-in

1 participant