Skip to content

Commit b47b4c2

Browse files
Update doc
1 parent 828c491 commit b47b4c2

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

docs/network-backends.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,29 @@ while True:
7373

7474
If we're working with an `async` codebase, then we need to select a different backend.
7575

76-
The `httpcore.AnyIOBackend` is suitable for usage if you're running under `asyncio`. This is a networking backend implemented using [the `anyio` package](https://anyio.readthedocs.io/en/3.x/).
76+
These `async` network backends are available:
77+
- `httpcore.AsyncioBackend` This networking backend is implemented using Pythons native `asyncio`.
78+
- `httpcore.AnyIOBackend` This is implemented using [the `anyio` package](https://anyio.readthedocs.io/en/3.x/).
79+
- `httpcore.TrioBackend` This is implemented using [`trio`](https://trio.readthedocs.io/en/stable/).
7780

81+
Currently by default `AnyIOBackend` is used when running with `asyncio` (this may change).
82+
`TrioBackend` is used by default when running with `trio`.
83+
84+
Using `httpcore.AsyncioBackend`:
85+
```python
86+
import httpcore
87+
import asyncio
88+
89+
async def main():
90+
network_backend = httpcore.AsyncioBackend()
91+
async with httpcore.AsyncConnectionPool(network_backend=network_backend) as http:
92+
response = await http.request('GET', 'https://www.example.com')
93+
print(response)
94+
95+
asyncio.run(main())
96+
```
97+
98+
Using `httpcore.AnyIOBackend`:
7899
```python
79100
import httpcore
80101
import asyncio

0 commit comments

Comments
 (0)