Skip to content

Commit

Permalink
async recommendations (#2727)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
trondhindenes and tomchristie committed Jun 15, 2023
1 parent 920333e commit 6d183a8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/async.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6d183a8

Please sign in to comment.