Repository navigation
Add max_retries and retry_wait_seconds settings so a caller can turn the automatic retries off - #51
Merged
Merged
Conversation
…n turn the automatic retries off, with the default keeping three attempts three seconds apart. The retry policy was fixed at import time on the v2 verbs, the v1 session helpers and the OAuth token manager. A per-client retrying wrapper now reads the setting on every call; which errors are retried is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r_attempt mention in a test docstring. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #51 +/- ##
==========================================
- Coverage 98.16% 98.11% -0.06%
==========================================
Files 96 97 +1
Lines 3823 3875 +52
==========================================
+ Hits 3753 3802 +49
- Misses 70 73 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Nov 23, 2026
…he async module and its generated sync twin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
Every network-facing call that hits a transient failure (network fault or 5xx) makes up to three attempts, three seconds apart, and decorators fix this policy at import time. A caller that already retries at its own level, such as a scheduler whose next pass repeats a failed job, cannot turn this off. A call that fails then takes up to three attempts, each with its own timeout, before the caller hears about it, and a deadline the caller sets around the call is hard to choose.
Fix
max_retriesandretry_wait_secondssettings on both clients, onGLPITokenManagerandGLPIV1Session, and asGLPI_MAX_RETRIES/GLPI_RETRY_WAIT_SECONDSforfrom_env.max_retriescounts the retries after the first attempt. The default2keeps the current three attempts, and0disables retrying, so a failing call raises after exactly one request.retry_wait_secondsis the pause between attempts (default 3 seconds).retried(retry_on)decorator in the new_retry.pybuilds the tenacity loop from the instance's settings. It covers the v2 verbs, the v1 session helpers and OAuth token acquisition. Each call site still decides which errors are retried, so the retried set is unchanged. The final error is re-raised as itself, never astenacity.RetryError.max_retries, a negativeretry_wait_seconds) raiseGlpiValidationError.unasync_build.py(one new token rule:AsyncRetrying->Retrying).Behaviour is unchanged unless a setting is passed.
Tests
test_retry_settings.pyon both trees covers:max_retries=0sends one request per verb;max_retriescounts the retries after the first;initSessionand the token manager, and the client passes it to these;from_envreads it;An autouse fixture now zeroes the default wait in tests. It replaces the monkeypatches on the old decorators.
Locally,
ruff check,mypy glpi_python_client,unasync_build.py --checkand the sphinx-Wbuild pass, and so do the test files this branch touches (218 passed). The full suite and the coverage gate run in CI.Overlaps with other open PRs
_async/auth/_v1_session.pyand_sync/auth/_v1_session.pyon one import line each (both imports are needed), and inCHANGELOG.md(keep both entries). I suggest merging Serialise GLPI v1 session renewals so concurrent requests open and kill the session once #50 first, then I rebase this branch.CHANGELOG.md.Suggested merge order: #50, #51, #52, #53. After each merge I rebase the next branch: the conflicts are the
CHANGELOG.mdentries, plus one import line in_v1_session.pyfor #51.🤖 Generated with Claude Code