Skip to content

feat: configurable HTTP timeout for Client requests - #43

Merged
samupl merged 1 commit into
masterfrom
feat/client-http-timeout
Nov 25, 2026
Merged

samupl merged 1 commit into
masterfrom
feat/client-http-timeout

Conversation

@samupl

@samupl samupl commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Problem

Client used a bare requests.Session() without a timeout, so a stalled KSeF connection (e.g. during send_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, or None (wait forever), passed to requests as-is for every request.
  • Implemented with a small requests.Session subclass that sets the default per request, so every existing and future self.session.* call is covered; an explicit per-request timeout still wins.
  • DEFAULT_CLIENT_TIMEOUT = 600 (deliberately generous; callers can lower it).
  • The auth classes (XadesAuthorization, TokenAuthorization) already accept timeout (default 30 s); unchanged.

Note: like all requests timeouts 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, and requests.Timeout propagates.

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.
@samupl
samupl merged commit 9a6c03f into master Nov 25, 2026
8 checks passed
@samupl samupl mentioned this pull request Nov 25, 2026
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.

1 participant