]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
async recommendations (#2727)
authorTrond Hindenes <trond@hindenes.com>
Thu, 15 Jun 2023 09:20:28 +0000 (10:20 +0100)
committerGitHub <noreply@github.com>
Thu, 15 Jun 2023 09:20:28 +0000 (12:20 +0300)
* async recommendations

* better

* Update docs/async.md

Co-authored-by: Tom Christie <tom@tomchristie.com>
* added async recommendation tweak

---------

Co-authored-by: Tom Christie <tom@tomchristie.com>
docs/async.md

index e22a2907e4194265cc3e81329600bcb3dcc0d325..1138c30c56b0c4bb2ec4dbacc99d157537b849ef 100644 (file)
@@ -53,6 +53,9 @@ async with httpx.AsyncClient() as client:
     ...
 ```
 
+!!! warning
+In order to get the most benefit from connection pooling, make sure you're not instantiating multiple client instances - for example by using `async with` inside a "hot loop". This can be achieved either by having a single scoped client that's passed throughout wherever it's needed, or by having a single global client instance.
+
 Alternatively, use `await client.aclose()` if you want to close a client explicitly:
 
 ```python