From: Andrew Chang-DeWitt <11323923+andrew-chang-dewitt@users.noreply.github.com> Date: Tue, 9 Jan 2024 17:45:52 +0000 (-0600) Subject: 📝 Add warning about lifecycle events with `AsyncClient` (#4167) X-Git-Tag: 0.109.0~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f43539d87406ea0afc52de3c54f352487024f6c;p=thirdparty%2Ffastapi%2Ffastapi.git 📝 Add warning about lifecycle events with `AsyncClient` (#4167) Co-authored-by: Sebastián Ramírez Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Marcelo Trylesinski --- diff --git a/docs/en/docs/advanced/async-tests.md b/docs/en/docs/advanced/async-tests.md index 9b39d70fca..c79822d63e 100644 --- a/docs/en/docs/advanced/async-tests.md +++ b/docs/en/docs/advanced/async-tests.md @@ -84,6 +84,9 @@ response = client.get('/') !!! tip 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 https://github.com/florimondmanca/asgi-lifespan#usage. + ## 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.