Repository navigation
Allow configurable timeouts for PycurlClient - #1975
Merged
mark-kogan-stripe merged 4 commits intoNov 13, 2026
Merged
mark-kogan-stripe merged 4 commits into
mark-kogan-stripe merged 4 commits into
Conversation
PycurlClient hardcoded CONNECTTIMEOUT=30 and TIMEOUT=80 on every request, unlike RequestsClient, HTTPXClient and AIOHTTPClient, which accept a `timeout` constructor argument. Add keyword-only `timeout` and `connect_timeout` arguments (defaults 80 and 30) after the existing parameters so positional callers are unaffected. Fixes stripe#1962
itsrayeedscodespace
requested review from
ramya-stripe
and removed request for
a team
November 11, 2026 18:44
|
|
mark-kogan-stripe
enabled auto-merge (squash)
November 13, 2026 16:38
Contributor
|
Looks Good! Thank you for the submission |
mark-kogan-stripe
approved these changes
Nov 13, 2026
Contributor
Author
|
thanks @mark-kogan-stripe and @ramya-stripe. if you guys are taking in interns for your team, please let me know and/or i'd appreciate it if you could give me a recruiter contact. i'm a super eager cs major at georgia tech and i really believe i could contribute to your team. please lmk about any openings :) |
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.
Fixes #1962
PycurlClienthardcodes its connection and total request timeouts, so callers currently have to override a private method to configure them.This adds keyword-only
timeout: int = 80andconnect_timeout: int = 30constructor arguments and applies them on every request after the curl handle is reset. Existing positional arguments, including the internal_libhook, retain their positions. Defaults remain 80 seconds for the whole transfer and 30 seconds for connection establishment. The same request path handles buffered and streamed responses and proxy configuration.Regression tests cover defaults, either timeout overridden independently, both overridden together, streaming, reapplying options on a reused curl handle, positional compatibility, and keyword-only enforcement. Tests run for the direct client and both existing proxy variants. Running these tests against upstream's pre-fix client produced 18 failures and 3 passing default cases. Keeping the new constructor but restoring hardcoded curl options produced 15 failures and 3 passing default cases, confirming that the tests also detect incorrect request execution.
Changelog:
.hark/changes/2026-11-06_itsrayeedscodespace_pycurl-configurable-timeouts.change.md(minor feature, links #1962).Validated on macOS arm64 with fresh environments, repository-pinned tooling, and stripe-mock 0.206.0 serving the repository's pinned OpenAPI v2596 spec and fixtures:
/tmp/stripe-1962-validation/bin/pytest tests/test_http_client.py -n 0/tmp/stripe-1962-validation/bin/pytest -n 4/tmp/stripe-1962-python39/bin/pytest tests/test_http_client.py -n 0/tmp/stripe-1962-python39-openssl/bin/pytest -n 4/tmp/stripe-1962-validation/bin/python -m flake8 --show-source stripe tests/tmp/stripe-1962-validation/bin/ruff format . --checkPYRIGHT_PYTHON_IGNORE_WARNINGS=1 /tmp/stripe-1962-validation/bin/pyright --pythonpath /tmp/stripe-1962-validation/bin/python/tmp/stripe-1962-validation/bin/mypy/tmp/stripe-1962-validation/bin/python -m build --outdir /tmp/stripe-1962-tools/dist/tmp/stripe-1962-validation/bin/python -m twine check /tmp/stripe-1962-tools/dist/*/tmp/stripe-1962-tools/hark validategit diff --check upstream/master...HEADAn additional local HTTP-server smoke check with real PycURL 7.49.0 passed for defaults, individual/combined overrides, buffered/streamed/reused requests, and positional
_libcalls. It also confirmed that the curl options reject floats andNone. PycURL was then removed from the static-check environment to match the declared test/dev dependencies; its installed wheel otherwise makes two existing import-ignore comments unnecessary.The initial full run on Apple's Python 3.9.6 had four export-test failures because its LibreSSL/urllib3 warning writes to stderr. Repeating the full suite on OpenSSL-based Python 3.9.25 resolved those environment failures without source changes. The other supported runtimes and operating systems remain for CI.
November 11 branch refresh
Merged upstream
38d853bcinto this branch ince7047cawithout rewriting history. Resolved the overlap with #1972 by applying configured timeout options to the thread-localcurlreturned by_get_curl(). Retained upstream's thread-isolation, concurrent-request, and close/reopen tests alongside all timeout regressions.Fresh validation from an isolated worktree on Python 3.13.18:
pytest tests/test_http_client.py -n 0: 160 passed.pytest -n 4: 4,467 passed, 7 skipped (351 warnings).git diff --check: passed.The initial test invocation could not connect to stripe-mock; tests passed after starting stripe-mock 0.206.0 with the pinned spec/fixtures. These results are local, not GitHub CI approval.