Skip to content

Conversation

cgoldshtein
Copy link

Add HTTPError to retryable errors for specific status codes (408, 429, 500, 503, 504, 507) and declare max retries in config variable. Improves reliability for temporary network issues.

Fixes #254

Add HTTPError to retryable errors for specific status codes (408, 429, 500, 503, 504, 507) and increase max retries to 3. Improves reliability for temporary network issues.

Fixes ckan#254
Copy link
Collaborator

@duttonw duttonw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got a failing test, could you also add a test for non retryable error (or link to where that is tested).

It would be good to a test which has all the 'error codes' you have in the list to show they all pass, and then a few extras which are should not retry. (ie. 404).
https://docs.pytest.org/en/stable/example/parametrize.html

=========================== short test summary info ============================
FAILED ckanext/xloader/tests/test_jobs.py::TestXLoaderJobs::test_retry_on_timeout_error - AssertionError: assert 'Express Load completed' in '2025-08-11 11:54:34,004 INFO  [ckan.cli] Using configuration file /__w/ckanext-xloader/ckanext-xloader/test.ini\n2025...025-08-11 11:54:34,623 INFO  [ckan.lib.jobs] Worker rq:worker:5a22d81466b34993bf8c7bf2415bf0b4 (PID 173) has stopped\n'
============= 1 failed, 103 passed, 5 skipped in 88.65s (0:01:28) ==============

return 'error' if errored else None


def handle_retryable_error(e, input, job_id, job_dict, logger, error_state):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function name should perhaps start with an underscore since it's internal.

Test all retryable errors (DB, HTTP timeouts) and non-retryable errors
(4xx HTTP codes) with single parametrized test method.
@duttonw duttonw merged commit fb0ff1c into ckan:master Sep 16, 2025
4 checks passed
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.

Add HTTPError to retryable errors and increase max retries for network failures
3 participants