Repository navigation
feat: configurable HTTP timeout for Client requests - #43
Merged
Merged
Conversation
Client requests had no timeout, so a stalled KSeF connection could hang a caller forever. Client now takes a timeout (seconds, a (connect, read) tuple, or None) applied to every request through its session; it defaults to DEFAULT_CLIENT_TIMEOUT (600 s). The auth classes already take their own timeout.
Closed
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
Clientused a barerequests.Session()without a timeout, so a stalled KSeF connection (e.g. duringsend_invoice_in_session) could block the caller indefinitely. Callers that reconcile uncertain uploads after a grace period need the upload to end, one way or another, within a known bound.Change
Client(..., timeout=DEFAULT_CLIENT_TIMEOUT): seconds, a(connect, read)tuple, orNone(wait forever), passed torequestsas-is for every request.requests.Sessionsubclass that sets the default per request, so every existing and futureself.session.*call is covered; an explicit per-requesttimeoutstill wins.DEFAULT_CLIENT_TIMEOUT = 600(deliberately generous; callers can lower it).XadesAuthorization,TokenAuthorization) already accepttimeout(default 30 s); unchanged.Note: like all
requeststimeouts this bounds connecting and each wait for data, not the total request time.Tests
New
tests/test_client_timeout.py: default applied, custom values (int, float, tuple,None), per-request override, a real API method sends the timeout, andrequests.Timeoutpropagates.