async recommendations (#2727)

* 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>
This commit is contained in:
Trond Hindenes 2023-06-15 10:20:28 +01:00 committed by GitHub
parent 920333ea98
commit 6d183a87e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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