From 35fa30da28ec6fc56e7d207bb7ca23406dad28c8 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Thu, 10 Feb 2022 13:24:28 +0100 Subject: [PATCH 1/2] Deprecate `WSGIMiddleware` in favor of `a2wsgi` --- docs/middleware.md | 4 ++++ starlette/middleware/wsgi.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/docs/middleware.md b/docs/middleware.md index f053e97fa..b21914291 100644 --- a/docs/middleware.md +++ b/docs/middleware.md @@ -305,3 +305,7 @@ can be used to profile and monitor distributed applications. A middleware class to emit timing information (cpu and wall time) for each request which passes through it. Includes examples for how to emit these timings as statsd metrics. + +#### [WSGIMiddleware](https://github.com/abersheeran/a2wsgi) + +A middleware class in charge of converting a WSGI application into an ASGI one. diff --git a/starlette/middleware/wsgi.py b/starlette/middleware/wsgi.py index 7e69e1a6b..9dbd06528 100644 --- a/starlette/middleware/wsgi.py +++ b/starlette/middleware/wsgi.py @@ -2,11 +2,18 @@ import math import sys import typing +import warnings import anyio from starlette.types import Receive, Scope, Send +warnings.warn( + "starlette.middleware.wsgi is deprecated and will be removed in a future release. " + "Please refer to https://github.com/abersheeran/a2wsgi as a replacement.", + DeprecationWarning, +) + def build_environ(scope: Scope, body: bytes) -> dict: """ From 286500ffb7abff474685d085a825d46b4f53d1d7 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Thu, 10 Feb 2022 13:27:19 +0100 Subject: [PATCH 2/2] Add deprecation warning to the setup.cfg --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 3089eaaf7..9f9c7b4eb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,6 +29,7 @@ filterwarnings= ignore: The 'variables' alias has been deprecated. Please use 'variable_values' instead\.:DeprecationWarning # Workaround for Python 3.9.7 (see https://bugs.python.org/issue45097) ignore:The loop argument is deprecated since Python 3\.8, and scheduled for removal in Python 3\.10\.:DeprecationWarning:asyncio + ignore: starlette\.middleware\.wsgi is deprecated and will be removed in a future release\.*:DeprecationWarning [coverage:run] source_pkgs = starlette, tests