From: Marcelo Trylesinski Date: Wed, 28 Sep 2022 06:14:05 +0000 (+0200) Subject: Remove note about `BackgroundTasks` being a limitation on the `BaseHTTPMiddleware... X-Git-Tag: 0.22.0~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2c152a53a3c822f5b77f0354a1d0ae07aee58e6d;p=thirdparty%2Fstarlette.git Remove note about `BackgroundTasks` being a limitation on the `BaseHTTPMiddleware` (#1874) Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com> --- diff --git a/docs/middleware.md b/docs/middleware.md index bf54c210..e84c361a 100644 --- a/docs/middleware.md +++ b/docs/middleware.md @@ -243,7 +243,6 @@ around explicitly, rather than mutating the middleware instance. Currently, the `BaseHTTPMiddleware` has some known limitations: -- It's not possible to use `BackgroundTasks` with `BaseHTTPMiddleware`. Check [#1438](https://github.com/encode/starlette/issues/1438) for more details. - Using `BaseHTTPMiddleware` will prevent changes to [`contextlib.ContextVar`](https://docs.python.org/3/library/contextvars.html#contextvars.ContextVar)s from propagating upwards. That is, if you set a value for a `ContextVar` in your endpoint and try to read it from a middleware you will find that the value is not the same value you set in your endpoint (see [this test](https://github.com/encode/starlette/blob/621abc747a6604825190b93467918a0ec6456a24/tests/middleware/test_base.py#L192-L223) for an example of this behavior). To overcome these limitations, use [pure ASGI middleware](#pure-asgi-middleware), as shown below.