From 772c24bd1940fa81ad5f670c46f7d98615079838 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Sat, 13 Apr 2024 14:39:55 +0200 Subject: [PATCH] Deprecate the `uvicorn.workers` module (#2302) --- docs/deployment.md | 9 +++++++++ docs/index.md | 9 +++++++++ uvicorn/workers.py | 7 +++++++ 3 files changed, 25 insertions(+) diff --git a/docs/deployment.md b/docs/deployment.md index 58927d95e..478632b28 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -182,6 +182,15 @@ Uvicorn provides a lightweight way to run multiple worker processes, for example ### Gunicorn +!!! warning + The `uvicorn.workers` module is deprecated and will be removed in a future release. + + You should use the [`uvicorn-worker`](https://github.com/Kludex/uvicorn-worker) package instead. + + ```bash + python -m pip install uvicorn-worker + ``` + Gunicorn is probably the simplest way to run and manage Uvicorn in a production setting. Uvicorn includes a gunicorn worker class that means you can get set up with very little configuration. The following will start Gunicorn with four worker processes: diff --git a/docs/index.md b/docs/index.md index 6ce92feb8..5d805316b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -262,6 +262,15 @@ if __name__ == "__main__": ### Running with Gunicorn +!!! warning + The `uvicorn.workers` module is deprecated and will be removed in a future release. + + You should use the [`uvicorn-worker`](https://github.com/Kludex/uvicorn-worker) package instead. + + ```bash + python -m pip install uvicorn-worker + ``` + [Gunicorn][gunicorn] is a mature, fully featured server and process manager. Uvicorn includes a Gunicorn worker class allowing you to run ASGI applications, diff --git a/uvicorn/workers.py b/uvicorn/workers.py index 3b46471e3..061805b6c 100644 --- a/uvicorn/workers.py +++ b/uvicorn/workers.py @@ -4,6 +4,7 @@ import logging import signal import sys +import warnings from typing import Any from gunicorn.arbiter import Arbiter @@ -12,6 +13,12 @@ from uvicorn.config import Config from uvicorn.main import Server +warnings.warn( + "The `uvicorn.workers` module is deprecated. Please use `uvicorn-worker` package instead.\n" + "For more details, see https://github.com/Kludex/uvicorn-worker.", + DeprecationWarning, +) + class UvicornWorker(Worker): """