📝 Add warning about lifecycle events with `AsyncClient` (#4167)

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
This commit is contained in:
Andrew Chang-DeWitt 2024-01-09 11:45:52 -06:00 committed by GitHub
parent d62b3ea69c
commit 6f43539d87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -84,6 +84,9 @@ response = client.get('/')
!!! tip !!! tip
Note that we're using async/await with the new `AsyncClient` - the request is asynchronous. Note that we're using async/await with the new `AsyncClient` - the request is asynchronous.
!!! warning
If your application relies on lifespan events, the `AsyncClient` won't trigger these events. To ensure they are triggered, use `LifespanManager` from <a href="florimondmanca/asgi-lifespan" class="external-link" target="_blank">https://github.com/florimondmanca/asgi-lifespan#usage</a>.
## Other Asynchronous Function Calls ## Other Asynchronous Function Calls
As the testing function is now asynchronous, you can now also call (and `await`) other `async` functions apart from sending requests to your FastAPI application in your tests, exactly as you would call them anywhere else in your code. As the testing function is now asynchronous, you can now also call (and `await`) other `async` functions apart from sending requests to your FastAPI application in your tests, exactly as you would call them anywhere else in your code.