Skip to content

Is httpx.Client thread safe? #1633

Answered by tomchristie
pfmoore asked this question in Q&A
May 10, 2021 · 5 comments · 8 replies
Discussion options

You must be logged in to vote

Yes. HTTPX is intended to be thread-safe, and yes, a single client-instance across all threads will do better in terms of connection pooling, than using an instance-per-thread.

We might want to figure a good place in the docs to write about this. (?)

I've not looked through requests or urllib3 to see where they choose to discuss this in their own docs. Their docs choices here might be a useful pointer for us.

(And thank you for the clearly framed question, much appreciated 💚)

Replies: 5 comments 8 replies

Comment options

You must be logged in to vote
3 replies
@pfmoore
Comment options

@ralokt
Comment options

@tomchristie
Comment options

Answer selected by tomchristie
Comment options

You must be logged in to vote
3 replies
@tomchristie
Comment options

@lee-cq
Comment options

@tomchristie
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@tomchristie
Comment options

@cosven
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
8 participants