Add 429 handling, HTTP timeouts, and per-record exception isolation#5
Open
Add 429 handling, HTTP timeouts, and per-record exception isolation#5
Conversation
Ports reliability fixes from Gluejar/regluit (PRs #1097, #1099, #1101, #1106, #1107, #1108) to doab-check. Same root causes, same fixes: - HTTP 429 rate-limit handling in OAI harvest loop (urllib.error.HTTPError) and in get_streamdata (response.status_code check before .json()) - timeout=(5, 60) on all requests.get() calls (doab_utils, check.py) - Per-record try/except with logger.exception() in load_doab_oai - limit=None guard (num_doabs >= None is TypeError in Python 3) - Timeout exception handler in ContentTyper (returns 524 tuple) Closes #2, closes #3, closes #4. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 tasks
When an SSL error triggered a retry with verify=False, a timeout on that retry would propagate uncaught instead of returning (524, '', ''). Wrap the SSL fallback in its own try/except to handle both Timeout and other exceptions gracefully. Found by Codex code review. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
|
Eric approves. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the reliability fixes from Gluejar/regluit (issue #1096, PRs #1097–#1108) to doab-check. Same root causes identified during the regluit DOAB harvester investigation.
Changes
doab_oai.py — OAI harvest loop:
limit is not Noneguard (Python 3TypeErroronint >= None)try/except Exceptionwithlogger.exception()— one bad record no longer kills the whole harvesturllib.error.HTTPErrorhandler for 429 — logsRetry-Afterheader and returns gracefullydoab_utils.py — bitstream API:
timeout=(5, 60)onrequests.get()inget_streamdata().json()(429 returns HTML, causing misleadingValueError)check.py — link checker / ContentTyper:
timeout=(5, 60)on all 6requests.get()callsrequests.exceptions.Timeouthandler returning(524, '', '')(consistent with existing timeout handling)Context
These are the same bugs that caused regluit's DOAB harvester to miss hundreds of books over several months. doab-check's codebase shares the same patterns and was vulnerable to the same failures.
Closes #2, closes #3, closes #4.