From: Vibhu Agarwal Date: Wed, 16 Jun 2021 05:19:39 +0000 (+0530) Subject: [Docs] Add AnyIO under "Supported async environments" (#1673) X-Git-Tag: 0.18.2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8cb7f5f02971f824970e94bd0d9b28daa4a1f15;p=thirdparty%2Fhttpx.git [Docs] Add AnyIO under "Supported async environments" (#1673) * [Docs] Add AnyIO under "Supported async environments" * Update docs/async.md Co-authored-by: Florimond Manca <15911462+florimondmanca@users.noreply.github.com> Co-authored-by: Florimond Manca <15911462+florimondmanca@users.noreply.github.com> Co-authored-by: Tom Christie --- diff --git a/docs/async.md b/docs/async.md index 360be8fe..1b3506c1 100644 --- a/docs/async.md +++ b/docs/async.md @@ -190,6 +190,29 @@ curio.run(main) !!! important The `curio` package must be installed to use the Curio backend. + +### [AnyIO](https://github.com/agronholm/anyio) + +AnyIO is an [asynchronous networking and concurrency library](https://anyio.readthedocs.io/) that works on top of either `asyncio` or `trio`. It blends in with native libraries of your chosen backend (defaults to `asyncio`). + +```python +import httpx +import anyio + +async def main(): + async with httpx.AsyncClient() as client: + response = await client.get('https://www.example.com/') + print(response) + +anyio.run(main, backend='trio') +``` + +When instantiating a transport instance explicitly, for maximum consistency, the same `backend` parameter can be passed to `AsyncHTTPTransport`. +```python +transport = httpx.AsyncHTTPTransport(backend="trio") +``` + + ## Calling into Python Web Apps Just as `httpx.Client` allows you to call directly into WSGI web applications,