]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
[Docs] Add AnyIO under "Supported async environments" (#1673)
authorVibhu Agarwal <vibhu4agarwal@gmail.com>
Wed, 16 Jun 2021 05:19:39 +0000 (10:49 +0530)
committerGitHub <noreply@github.com>
Wed, 16 Jun 2021 05:19:39 +0000 (07:19 +0200)
* [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 <tom@tomchristie.com>
docs/async.md

index 360be8feaa4728bea3cf49bca90b6f8f53144eeb..1b3506c18b9cc52d9461a304ae7c5e1aa51e688d 100644 (file)
@@ -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,