Repository navigation
Use a separate Curl handle per thread in PycurlClient - #1972
Merged
Merged
Conversation
PycurlClient created one pycurl.Curl handle in its constructor and reconfigured it for every request with no synchronization. When one client was shared across threads, concurrent requests could overwrite each other's URL, body, and headers, sending one request with another request's API key and Stripe-Account. Each thread now lazily creates its own handle in the client's existing thread-local storage, so connections are still reused within a thread. close() closes the current thread's handle. Closes RUN_DEVSDK-3704 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Committed-By-Agent: claude
zacchua-stripe
marked this pull request as ready for review
November 10, 2026 22:15
zacchua-stripe
requested review from
mark-kogan-stripe and
ramya-stripe
and removed request for
a team
November 10, 2026 22:15
jar-stripe
approved these changes
Nov 11, 2026
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.
Why?
PycurlClientcreated a singlepycurl.Curlhandle in its constructor and reconfigured it for every request (reset(),setopt(),perform(),getinfo()) with no synchronization. libcurl forbids using an easy handle from more than one thread at a time (docs underHandles). When one client was shared across threads, concurrent requests could overwrite each other's URL, body, and headers. One request could then go out with another request'sAuthorizationandStripe-Account.What?
RequestsClientkeeps a per-thread session (link). Connections are still reused within a thread.close()closes the current thread's handle.close().See Also
http://go/j/RUN_DEVSDK-3704
Configuration
skip-changefile: This PR is not a user-facing change, so there's no changefile.