From: Trond Hindenes Date: Thu, 15 Jun 2023 09:20:28 +0000 (+0100) Subject: async recommendations (#2727) X-Git-Tag: 0.25.0~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d183a87e1f81c7132482d0ee56f44e2afdffef2;p=thirdparty%2Fhttpx.git async recommendations (#2727) * async recommendations * better * Update docs/async.md Co-authored-by: Tom Christie * added async recommendation tweak --------- Co-authored-by: Tom Christie --- diff --git a/docs/async.md b/docs/async.md index e22a2907..1138c30c 100644 --- a/docs/async.md +++ b/docs/async.md @@ -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