From be25d3bb3a4e842361ac8508caca19d266375bdf Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 1 Jan 2025 12:55:27 +0100 Subject: [PATCH 1/4] docs: replace `tools/cli_usage.py` by mkdocs plugin (#2551) --- docs/deployment.md | 114 +------------------------------------------ docs/index.md | 113 +----------------------------------------- docs/plugins/main.py | 22 +++++++-- scripts/check | 1 - scripts/lint | 1 - tools/cli_usage.py | 70 -------------------------- 6 files changed, 23 insertions(+), 298 deletions(-) delete mode 100644 tools/cli_usage.py diff --git a/docs/deployment.md b/docs/deployment.md index d69fcf88e..5fa2a43f5 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -25,120 +25,10 @@ The `--reload` and `--workers` arguments are **mutually exclusive**. To see the complete set of available options, use `uvicorn --help`: - -``` -$ uvicorn --help -Usage: uvicorn [OPTIONS] APP - -Options: - --host TEXT Bind socket to this host. [default: - 127.0.0.1] - --port INTEGER Bind socket to this port. If 0, an available - port will be picked. [default: 8000] - --uds TEXT Bind to a UNIX domain socket. - --fd INTEGER Bind to socket from this file descriptor. - --reload Enable auto-reload. - --reload-dir PATH Set reload directories explicitly, instead - of using the current working directory. - --reload-include TEXT Set glob patterns to include while watching - for files. Includes '*.py' by default; these - defaults can be overridden with `--reload- - exclude`. This option has no effect unless - watchfiles is installed. - --reload-exclude TEXT Set glob patterns to exclude while watching - for files. Includes '.*, .py[cod], .sw.*, - ~*' by default; these defaults can be - overridden with `--reload-include`. This - option has no effect unless watchfiles is - installed. - --reload-delay FLOAT Delay between previous and next check if - application needs to be. Defaults to 0.25s. - [default: 0.25] - --workers INTEGER Number of worker processes. Defaults to the - $WEB_CONCURRENCY environment variable if - available, or 1. Not valid with --reload. - --loop [auto|asyncio|uvloop] Event loop implementation. [default: auto] - --http [auto|h11|httptools] HTTP protocol implementation. [default: - auto] - --ws [auto|none|websockets|wsproto] - WebSocket protocol implementation. - [default: auto] - --ws-max-size INTEGER WebSocket max size message in bytes - [default: 16777216] - --ws-max-queue INTEGER The maximum length of the WebSocket message - queue. [default: 32] - --ws-ping-interval FLOAT WebSocket ping interval in seconds. - [default: 20.0] - --ws-ping-timeout FLOAT WebSocket ping timeout in seconds. - [default: 20.0] - --ws-per-message-deflate BOOLEAN - WebSocket per-message-deflate compression - [default: True] - --lifespan [auto|on|off] Lifespan implementation. [default: auto] - --interface [auto|asgi3|asgi2|wsgi] - Select ASGI3, ASGI2, or WSGI as the - application interface. [default: auto] - --env-file PATH Environment configuration file. - --log-config PATH Logging configuration file. Supported - formats: .ini, .json, .yaml. - --log-level [critical|error|warning|info|debug|trace] - Log level. [default: info] - --access-log / --no-access-log Enable/Disable access log. - --use-colors / --no-use-colors Enable/Disable colorized logging. - --proxy-headers / --no-proxy-headers - Enable/Disable X-Forwarded-Proto, - X-Forwarded-For, X-Forwarded-Port to - populate remote address info. - --server-header / --no-server-header - Enable/Disable default Server header. - --date-header / --no-date-header - Enable/Disable default Date header. - --forwarded-allow-ips TEXT Comma separated list of IP Addresses, IP - Networks, or literals (e.g. UNIX Socket - path) to trust with proxy headers. Defaults - to the $FORWARDED_ALLOW_IPS environment - variable if available, or '127.0.0.1'. The - literal '*' means trust everything. - --root-path TEXT Set the ASGI 'root_path' for applications - submounted below a given URL path. - --limit-concurrency INTEGER Maximum number of concurrent connections or - tasks to allow, before issuing HTTP 503 - responses. - --backlog INTEGER Maximum number of connections to hold in - backlog - --limit-max-requests INTEGER Maximum number of requests to service before - terminating the process. - --timeout-keep-alive INTEGER Close Keep-Alive connections if no new data - is received within this timeout. [default: - 5] - --timeout-graceful-shutdown INTEGER - Maximum number of seconds to wait for - graceful shutdown. - --ssl-keyfile TEXT SSL key file - --ssl-certfile TEXT SSL certificate file - --ssl-keyfile-password TEXT SSL keyfile password - --ssl-version INTEGER SSL version to use (see stdlib ssl module's) - [default: 17] - --ssl-cert-reqs INTEGER Whether client certificate is required (see - stdlib ssl module's) [default: 0] - --ssl-ca-certs TEXT CA certificates file - --ssl-ciphers TEXT Ciphers to use (see stdlib ssl module's) - [default: TLSv1] - --header TEXT Specify custom default HTTP response headers - as a Name:Value pair - --version Display the uvicorn version and exit. - --app-dir TEXT Look for APP in the specified directory, by - adding this to the PYTHONPATH. Defaults to - the current working directory. - --h11-max-incomplete-event-size INTEGER - For h11, the maximum number of bytes to - buffer of an incomplete event. - --factory Treat APP as an application factory, i.e. a - () -> callable. - --help Show this message and exit. +```bash +{{ uvicorn_help }} ``` - See the [settings documentation](settings.md) for more details on the supported options for running uvicorn. ## Running programmatically diff --git a/docs/index.md b/docs/index.md index bb6fc321a..293361e37 100644 --- a/docs/index.md +++ b/docs/index.md @@ -95,117 +95,8 @@ The uvicorn command line tool is the easiest way to run your application. ### Command line options - -``` -$ uvicorn --help -Usage: uvicorn [OPTIONS] APP - -Options: - --host TEXT Bind socket to this host. [default: - 127.0.0.1] - --port INTEGER Bind socket to this port. If 0, an available - port will be picked. [default: 8000] - --uds TEXT Bind to a UNIX domain socket. - --fd INTEGER Bind to socket from this file descriptor. - --reload Enable auto-reload. - --reload-dir PATH Set reload directories explicitly, instead - of using the current working directory. - --reload-include TEXT Set glob patterns to include while watching - for files. Includes '*.py' by default; these - defaults can be overridden with `--reload- - exclude`. This option has no effect unless - watchfiles is installed. - --reload-exclude TEXT Set glob patterns to exclude while watching - for files. Includes '.*, .py[cod], .sw.*, - ~*' by default; these defaults can be - overridden with `--reload-include`. This - option has no effect unless watchfiles is - installed. - --reload-delay FLOAT Delay between previous and next check if - application needs to be. Defaults to 0.25s. - [default: 0.25] - --workers INTEGER Number of worker processes. Defaults to the - $WEB_CONCURRENCY environment variable if - available, or 1. Not valid with --reload. - --loop [auto|asyncio|uvloop] Event loop implementation. [default: auto] - --http [auto|h11|httptools] HTTP protocol implementation. [default: - auto] - --ws [auto|none|websockets|wsproto] - WebSocket protocol implementation. - [default: auto] - --ws-max-size INTEGER WebSocket max size message in bytes - [default: 16777216] - --ws-max-queue INTEGER The maximum length of the WebSocket message - queue. [default: 32] - --ws-ping-interval FLOAT WebSocket ping interval in seconds. - [default: 20.0] - --ws-ping-timeout FLOAT WebSocket ping timeout in seconds. - [default: 20.0] - --ws-per-message-deflate BOOLEAN - WebSocket per-message-deflate compression - [default: True] - --lifespan [auto|on|off] Lifespan implementation. [default: auto] - --interface [auto|asgi3|asgi2|wsgi] - Select ASGI3, ASGI2, or WSGI as the - application interface. [default: auto] - --env-file PATH Environment configuration file. - --log-config PATH Logging configuration file. Supported - formats: .ini, .json, .yaml. - --log-level [critical|error|warning|info|debug|trace] - Log level. [default: info] - --access-log / --no-access-log Enable/Disable access log. - --use-colors / --no-use-colors Enable/Disable colorized logging. - --proxy-headers / --no-proxy-headers - Enable/Disable X-Forwarded-Proto, - X-Forwarded-For, X-Forwarded-Port to - populate remote address info. - --server-header / --no-server-header - Enable/Disable default Server header. - --date-header / --no-date-header - Enable/Disable default Date header. - --forwarded-allow-ips TEXT Comma separated list of IP Addresses, IP - Networks, or literals (e.g. UNIX Socket - path) to trust with proxy headers. Defaults - to the $FORWARDED_ALLOW_IPS environment - variable if available, or '127.0.0.1'. The - literal '*' means trust everything. - --root-path TEXT Set the ASGI 'root_path' for applications - submounted below a given URL path. - --limit-concurrency INTEGER Maximum number of concurrent connections or - tasks to allow, before issuing HTTP 503 - responses. - --backlog INTEGER Maximum number of connections to hold in - backlog - --limit-max-requests INTEGER Maximum number of requests to service before - terminating the process. - --timeout-keep-alive INTEGER Close Keep-Alive connections if no new data - is received within this timeout. [default: - 5] - --timeout-graceful-shutdown INTEGER - Maximum number of seconds to wait for - graceful shutdown. - --ssl-keyfile TEXT SSL key file - --ssl-certfile TEXT SSL certificate file - --ssl-keyfile-password TEXT SSL keyfile password - --ssl-version INTEGER SSL version to use (see stdlib ssl module's) - [default: 17] - --ssl-cert-reqs INTEGER Whether client certificate is required (see - stdlib ssl module's) [default: 0] - --ssl-ca-certs TEXT CA certificates file - --ssl-ciphers TEXT Ciphers to use (see stdlib ssl module's) - [default: TLSv1] - --header TEXT Specify custom default HTTP response headers - as a Name:Value pair - --version Display the uvicorn version and exit. - --app-dir TEXT Look for APP in the specified directory, by - adding this to the PYTHONPATH. Defaults to - the current working directory. - --h11-max-incomplete-event-size INTEGER - For h11, the maximum number of bytes to - buffer of an incomplete event. - --factory Treat APP as an application factory, i.e. a - () -> callable. - --help Show this message and exit. +```bash +{{ uvicorn_help }} ``` For more information, see the [settings documentation](settings.md). diff --git a/docs/plugins/main.py b/docs/plugins/main.py index 12262c39f..ac7c1542e 100644 --- a/docs/plugins/main.py +++ b/docs/plugins/main.py @@ -1,6 +1,7 @@ from __future__ import annotations as _annotations import re +import subprocess from mkdocs.config import Config from mkdocs.structure.files import Files @@ -8,9 +9,7 @@ def on_page_content(html: str, page: Page, config: Config, files: Files) -> str: - """ - Called on each page after the markdown is converted to HTML. - """ + """Called on each page after the markdown is converted to HTML.""" html = add_hyperlink_to_pull_request(html, page, config, files) return html @@ -24,3 +23,20 @@ def add_hyperlink_to_pull_request(html: str, page: Page, config: Config, files: return html return re.sub(r"\(#(\d+)\)", r"(#\1)", html) + + +def on_page_markdown(markdown: str, page: Page, config: Config, files: Files) -> str: + """Called on each file after it is read and before it is converted to HTML.""" + markdown = uvicorn_print_help(markdown, page) + return markdown + + +def uvicorn_print_help(markdown: str, page: Page) -> str: + # if you don't filter to the specific route that needs this substitution, things will be very slow + print(page.file.src_uri) + if page.file.src_uri not in ("index.md", "deployment.md"): + return markdown + + output = subprocess.run(["uvicorn", "--help"], capture_output=True, check=True) + logfire_help = output.stdout.decode() + return re.sub(r"{{ *uvicorn_help *}}", logfire_help, markdown) diff --git a/scripts/check b/scripts/check index 15748a4e8..10e422cbf 100755 --- a/scripts/check +++ b/scripts/check @@ -13,4 +13,3 @@ set -x ${PREFIX}ruff format --check --diff $SOURCE_FILES ${PREFIX}mypy $SOURCE_FILES ${PREFIX}ruff check $SOURCE_FILES -${PREFIX}python -m tools.cli_usage --check diff --git a/scripts/lint b/scripts/lint index 1b04d208e..f22e77f95 100755 --- a/scripts/lint +++ b/scripts/lint @@ -11,4 +11,3 @@ set -x ${PREFIX}ruff format $SOURCE_FILES ${PREFIX}ruff check --fix $SOURCE_FILES -${PREFIX}python -m tools.cli_usage diff --git a/tools/cli_usage.py b/tools/cli_usage.py deleted file mode 100644 index 1cfa88672..000000000 --- a/tools/cli_usage.py +++ /dev/null @@ -1,70 +0,0 @@ -""" -Look for a marker comment in docs pages, and place the output of -`$ uvicorn --help` there. Pass `--check` to ensure the content is in sync. -""" - -from __future__ import annotations - -import argparse -import subprocess -import sys -from pathlib import Path - - -def _get_usage_lines() -> list[str]: - res = subprocess.run(["uvicorn", "--help"], stdout=subprocess.PIPE) - help_text = res.stdout.decode("utf-8") - return ["```", "$ uvicorn --help", *help_text.splitlines(), "```"] - - -def _find_next_codefence_lineno(lines: list[str], after: int) -> int: - return next(lineno for lineno, line in enumerate(lines[after:], after) if line == "```") - - -def _get_insert_location(lines: list[str]) -> tuple[int, int]: - marker = lines.index("") - start = marker + 1 - - if lines[start] == "```": - # Already generated. - # - # ``` <- start - # [...] - # ``` <- end - next_codefence = _find_next_codefence_lineno(lines, after=start + 1) - end = next_codefence + 1 - else: - # Not generated yet. - end = start - - return start, end - - -def _generate_cli_usage(path: Path, check: bool = False) -> int: - content = path.read_text() - - lines = content.splitlines() - usage_lines = _get_usage_lines() - start, end = _get_insert_location(lines) - lines = lines[:start] + usage_lines + lines[end:] - output = "\n".join(lines) + "\n" - - if check: - if content == output: - return 0 - print(f"ERROR: CLI usage in {path} is out of sync. Run scripts/lint to fix.") - return 1 - - path.write_text(output) - return 0 - - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("--check", action="store_true") - args = parser.parse_args() - paths = [Path("docs", "index.md"), Path("docs", "deployment.md")] - rv = 0 - for path in paths: - rv |= _generate_cli_usage(path, check=args.check) - sys.exit(rv) From 80c076404ea486a3a6a90ea0f35f1cdb2b528e14 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 1 Jan 2025 12:59:57 +0100 Subject: [PATCH 2/4] Move changelog to release notes (#2550) * Move changelog to release notes * cahnge sync version script --- CHANGELOG.md | 654 -------------------------- docs/deployment.md | 2 - docs/overrides/partials/toc-item.html | 18 + docs/release-notes.md | 652 ++++++++++++++++++++++++- pyproject.toml | 2 +- scripts/sync-version | 2 +- 6 files changed, 671 insertions(+), 659 deletions(-) delete mode 100644 CHANGELOG.md create mode 100644 docs/overrides/partials/toc-item.html diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index e37e8e19a..000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,654 +0,0 @@ -# Change Log - -## 0.34.0 (2024-12-15) - -### Added - -* Add `content-length` to 500 response in `wsproto` implementation (#2542) - -### Removed - -* Drop support for Python 3.8 (#2543) - -## 0.33.0 (2024-12-14) - -### Removed - -* Remove `WatchGod` support for `--reload` (#2536) - -## 0.32.1 (2024-11-20) - -### Fixed - -* Drop ASGI spec version to 2.3 on HTTP scope (#2513) -* Enable httptools lenient data on `httptools >= 0.6.3` (#2488) - -## 0.32.0 (2024-10-15) - -### Added - -* Officially support Python 3.13 (#2482) -* Warn when `max_request_limit` is exceeded (#2430) - -## 0.31.1 (2024-10-09) - -### Fixed - -* Support WebSockets 0.13.1 (#2471) -* Restore support for `[*]` in trusted hosts (#2480) -* Add `PathLike[str]` type hint for `ssl_keyfile` (#2481) - -## 0.31.0 (2024-09-27) - -### Added - -Improve `ProxyHeadersMiddleware` (#2468) and (#2231): - -- Fix the host for requests from clients running on the proxy server itself. -- Fallback to host that was already set for empty x-forwarded-for headers. -- Also allow to specify IP Networks as trusted hosts. This greatly simplifies deployments - on docker swarm/kubernetes, where the reverse proxy might have a dynamic IP. - - This includes support for IPv6 Address/Networks. - -## 0.30.6 (2024-08-13) - -### Fixed - -- Don't warn when upgrade is not WebSocket and depedencies are installed (#2360) - -## 0.30.5 (2024-08-02) - -### Fixed - -- Don't close connection before receiving body on H11 (#2408) - -## 0.30.4 (2024-07-31) - -### Fixed - -- Close connection when `h11` sets client state to `MUST_CLOSE` (#2375) - -## 0.30.3 (2024-07-20) - -### Fixed - -- Suppress `KeyboardInterrupt` from CLI and programmatic usage (#2384) -- `ClientDisconnect` inherits from `OSError` instead of `IOError` (#2393) - -## 0.30.2 (2024-07-20) - -### Added - -- Add `reason` support to [`websocket.disconnect`](https://asgi.readthedocs.io/en/latest/specs/www.html#disconnect-receive-event-ws) event (#2324) - -### Fixed - -- Iterate subprocesses in-place on the process manager (#2373) - -## 0.30.1 (2024-06-02) - -### Fixed - -- Allow horizontal tabs `\t` in response header values (#2345) - -## 0.30.0 (2024-05-28) - -### Added - -- New multiprocess manager (#2183) -- Allow `ConfigParser` or a `io.IO[Any]` on `log_config` (#1976) - -### Fixed - -- Suppress side-effects of signal propagation (#2317) -- Send `content-length` header on 5xx (#2304) - -### Deprecated - -- Deprecate the `uvicorn.workers` module (#2302) - -## 0.29.0 (2024-03-19) - -### Added - -- Cooperative signal handling (#1600) - -## 0.28.1 (2024-03-19) - -### Fixed - -- Revert raise `ClientDisconnected` on HTTP (#2276) - -## 0.28.0 (2024-03-09) - -### Added - -- Raise `ClientDisconnected` on `send()` when client disconnected (#2220) - -### Fixed - -- Except `AttributeError` on `sys.stdin.fileno()` for Windows IIS10 (#1947) -- Use `X-Forwarded-Proto` for WebSockets scheme when the proxy provides it (#2258) - -## 0.27.1 (2024-02-10) - -- Fix spurious LocalProtocolError errors when processing pipelined requests (#2243) - -## 0.27.0.post1 (2024-01-29) - -### Fixed - -- Fix nav overrides for newer version of Mkdocs Material (#2233) - -## 0.27.0 (2024-01-22) - -### Added - -- Raise `ClientDisconnect(IOError)` on `send()` when client disconnected (#2218) -- Bump ASGI WebSocket spec version to 2.4 (#2221) - -## 0.26.0 (2024-01-16) - -### Changed - -- Update `--root-path` to include the root path prefix in the full ASGI `path` as per the ASGI spec (#2213) -- Use `__future__.annotations` on some internal modules (#2199) - -## 0.25.0 (2023-12-17) - -### Added - -- Support the WebSocket Denial Response ASGI extension (#1916) - -### Fixed - -- Allow explicit hidden file paths on `--reload-include` (#2176) -- Properly annotate `uvicorn.run()` (#2158) - -## 0.24.0.post1 (2023-11-06) - -### Fixed - -- Revert mkdocs-material from 9.1.21 to 9.2.6 (#2148) - -## 0.24.0 (2023-11-04) - -### Added - -- Support Python 3.12 (#2145) -- Allow setting `app` via environment variable `UVICORN_APP` (#2106) - -## 0.23.2 (2023-07-31) - -### Fixed - -- Maintain the same behavior of `websockets` from 10.4 on 11.0 (#2061) - -## 0.23.1 (2023-07-18) - -### Fixed - -- Add `typing_extensions` for Python 3.10 and lower (#2053) - -## 0.23.0 (2023-07-10) - -### Added - -- Add `--ws-max-queue` parameter WebSockets (#2033) - -### Removed - -- Drop support for Python 3.7 (#1996) -- Remove `asgiref` as typing dependency (#1999) - -### Fixed - -- Set `scope["scheme"]` to `ws` or `wss` instead of `http` or `https` on `ProxyHeadersMiddleware` for WebSockets (#2043) - -### Changed - -- Raise `ImportError` on circular import (#2040) -- Use `logger.getEffectiveLevel()` instead of `logger.level` to check if log level is `TRACE` (#1966) - -## 0.22.0 (2023-04-28) - -### Added - -- Add `--timeout-graceful-shutdown` parameter (#1950) -- Handle `SIGBREAK` on Windows (#1909) - -### Fixed - -- Shutdown event is now being triggered on Windows when using hot reload (#1584) -- `--reload-delay` is effectively used on the `watchfiles` reloader (#1930) - -## 0.21.1 (2023-03-16) - -### Fixed - -- Reset lifespan state on each request (#1903) - -## 0.21.0 (2023-03-09) - -### Added - -- Introduce lifespan state (#1818) -- Allow headers to be sent as iterables on H11 implementation (#1782) -- Improve discoverability when --port=0 is used (#1890) - -### Changed - -- Avoid importing `h11` and `pyyaml` when not needed to improve import time (#1846) -- Replace current native `WSGIMiddleware` implementation by `a2wsgi` (#1825) -- Change default `--app-dir` from "." (dot) to "" (empty string) (#1835) - -### Fixed - -- Send code 1012 on shutdown for WebSockets (#1816) -- Use `surrogateescape` to encode headers on `websockets` implementation (#1005) -- Fix warning message on reload failure (#1784) - -## 0.20.0 (2022-11-20) - -### Added - -- Check if handshake is completed before sending frame on `wsproto` shutdown (#1737) -- Add default headers to WebSockets implementations (#1606 & #1747) -- Warn user when `reload` and `workers` flag are used together (#1731) - -### Fixed - -- Use correct `WebSocket` error codes on `close` (#1753) -- Send disconnect event on connection lost for `wsproto` (#996) -- Add `SIGQUIT` handler to `UvicornWorker` (#1710) -- Fix crash on exist with "--uds" if socket doesn't exist (#1725) -- Annotate `CONFIG_KWARGS` in `UvicornWorker` class (#1746) - -### Removed - -- Remove conditional on `RemoteProtocolError.event_hint` on `wsproto` (#1486) -- Remove unused `handle_no_connect` on `wsproto` implementation (#1759) - -## 0.19.0 (2022-10-19) - -### Added - -- Support Python 3.11 (#1652) -- Bump minimal `httptools` version to `0.5.0` (#1645) -- Ignore HTTP/2 upgrade and optionally ignore WebSocket upgrade (#1661) -- Add `py.typed` to comply with PEP 561 (#1687) - -### Fixed - -- Set `propagate` to `False` on "uvicorn" logger (#1288) -- USR1 signal is now handled correctly on `UvicornWorker`. (#1565) -- Use path with query string on `WebSockets` logs (#1385) -- Fix behavior on which "Date" headers were not updated on the same connection (#1706) - -### Removed - -- Remove the `--debug` flag (#1640) -- Remove the `DebugMiddleware` (#1697) - -## 0.18.3 (2022-08-24) - -### Fixed - -- Remove cyclic references on HTTP implementations. (#1604) - -### Changed - -- `reload_delay` default changed from `None` to `0.25` on `uvicorn.run()` and `Config`. `None` is not an acceptable value anymore. (#1545) - -## 0.18.2 (2022-06-27) - -### Fixed - -- Add default `log_config` on `uvicorn.run()` (#1541) -- Revert `logging` file name modification (#1543) - -## 0.18.1 (2022-06-23) - -### Fixed - -- Use `DEFAULT_MAX_INCOMPLETE_EVENT_SIZE` as default to `h11_max_incomplete_event_size` on the CLI (#1534) - -## 0.18.0 (2022-06-23) - -### Added - -- The `reload` flag prioritizes `watchfiles` instead of the deprecated `watchgod` (#1437) -- Annotate `uvicorn.run()` function (#1423) -- Allow configuring `max_incomplete_event_size` for `h11` implementation (#1514) - -### Removed - -- Remove `asgiref` dependency (#1532) - -### Fixed - -- Turn `raw_path` into bytes on both websockets implementations (#1487) -- Revert log exception traceback in case of invalid HTTP request (#1518) -- Set `asyncio.WindowsSelectorEventLoopPolicy()` when using multiple workers to avoid "WinError 87" (#1454) - -## 0.17.6 (2022-03-11) - -### Changed - -- Change `httptools` range to `>=0.4.0` (#1400) - -## 0.17.5 (2022-02-16) - -### Fixed - -- Fix case where url is fragmented in httptools protocol (#1263) -- Fix WSGI middleware not to explode quadratically in the case of a larger body (#1329) - -### Changed - -- Send HTTP 400 response for invalid request (#1352) - -## 0.17.4 (2022-02-04) - -### Fixed - -- Replace `create_server` by `create_unix_server` (#1362) - -## 0.17.3 (2022-02-03) - -### Fixed - -- Drop wsproto version checking. (#1359) - -## 0.17.2 (2022-02-03) - -### Fixed - -- Revert #1332. While trying to solve the memory leak, it introduced an issue (#1345) when the server receives big chunks of data using the `httptools` implementation. (#1354) -- Revert stream interface changes. This was introduced on 0.14.0, and caused an issue (#1226), which caused a memory leak when sending TCP pings. (#1355) -- Fix wsproto version check expression (#1342) - -## 0.17.1 (2022-01-28) - -### Fixed - -- Move all data handling logic to protocol and ensure connection is closed. (#1332) -- Change `spec_version` field from "2.1" to "2.3", as Uvicorn is compliant with that version of the ASGI specifications. (#1337) - -## 0.17.0.post1 (2022-01-24) - -### Fixed - -- Add the `python_requires` version specifier (#1328) - -## 0.17.0 (2022-01-14) - -### Added - -- Allow configurable websocket per-message-deflate setting (#1300) -- Support extra_headers for WS accept message (#1293) -- Add missing http version on websockets scope (#1309) - -### Fixed/Removed - -- Drop Python 3.6 support (#1261) -- Fix reload process behavior when exception is raised (#1313) -- Remove `root_path` from logs (#1294) - -## 0.16.0 (2021-12-08) - -### Added - -- Enable read of uvicorn settings from environment variables (#1279) -- Bump `websockets` to 10.0. (#1180) -- Ensure non-zero exit code when startup fails (#1278) -- Increase `httptools` version range from "==0.2.*" to ">=0.2.0,<0.4.0". (#1243) -- Override default asyncio event loop with reload only on Windows (#1257) -- Replace `HttpToolsProtocol.pipeline` type from `list` to `deque`. (#1213) -- Replace `WSGIResponder.send_queue` type from `list` to `deque`. (#1214) - -### Fixed - -- Main process exit after startup failure on reloader classes (#1177) -- Add explicit casting on click options (#1217) -- Allow WebSocket close event to receive reason being None from ASGI app. (#1259) -- Fix a bug in `WebSocketProtocol.asgi_receive` on which we returned a close frame even if there were data messages before that frame in the read queue. (#1252) -- The option `--reload-dirs` was splitting a string into single character directories. (#1267) -- Only second SIGINT is able to forcefully shutdown the server (#1269) -- Allow app-dir parameter on the run() function (#1271) - -## 0.15.0 (2021-08-13) - -### Added - -- Change reload to be configurable with glob patterns. Currently only `.py` files are watched, which is different from the previous default behavior. (#820) -- Add Python 3.10-rc.1 support. Now the server uses `asyncio.run` which will: start a fresh asyncio event loop, on shutdown cancel any background tasks rather than aborting them, `aexit` any remaining async generators, and shutdown the default `ThreadPoolExecutor`. (#1070) -- Exit with status 3 when worker starts failed (#1077) -- Add option to set websocket ping interval and timeout (#1048) -- Adapt bind_socket to make it usable with multiple processes (#1009) -- Add existence check to the reload directory(ies) (#1089) -- Add missing trace log for websocket protocols (#1083) -- Support disabling default Server and Date headers (#818) - -### Changed - -- Add PEP440 compliant version of click (#1099) -- Bump asgiref to 3.4.0 (#1100) - -### Fixed - -- When receiving a `SIGTERM` supervisors now terminate their processes before joining them (#1069) -- Fix the need of `httptools` on minimal installation (#1135) -- Fix ping parameters annotation in Config class (#1127) - -## 0.14.0 (2021-06-01) - -### Added - -- Defaults ws max_size on server to 16MB (#995) -- Improve user feedback if no ws library installed (#926 and #1023) -- Support 'reason' field in 'websocket.close' messages (#957) -- Implemented lifespan.shutdown.failed (#755) - -### Changed - -- Upgraded websockets requirements (#1065) -- Switch to asyncio streams API (#869) -- Update httptools from 0.1.* to 0.2.* (#1024) -- Allow Click 8.0, refs #1016 (#1042) -- Add search for a trusted host in ProxyHeadersMiddleware (#591) -- Up wsproto to 1.0.0 (#892) - -### Fixed - -- Force reload_dirs to be a list (#978) -- Fix gunicorn worker not running if extras not installed (#901) -- Fix socket port 0 (#975) -- Prevent garbage collection of main lifespan task (#972) - -## 0.13.4 (2021-02-20) - -### Fixed - -- Fixed wsgi middleware PATH_INFO encoding (#962) -- Fixed uvloop dependency (#952) then (#959) -- Relax watchgod up bound (#946) -- Return 'connection: close' header in response (#721) - -### Added - -- Docs: Nginx + websockets (#948) -- Document the default value of 1 for workers (#940) (#943) -- Enabled permessage-deflate extension in websockets (#764) - -## 0.13.3 (2020-12-29) - -### Fixed - -- Prevent swallowing of return codes from `subprocess` when running with Gunicorn by properly resetting signals. (#895) -- Tweak detection of app factories to be more robust. A warning is now logged when passing a factory without the `--factory` flag. (#914) -- Properly clean tasks when handshake is aborted when running with `--ws websockets`. (#921) - -## 0.13.2 (2020-12-12) - -### Fixed - -- Log full exception traceback in case of invalid HTTP request. (#886 and #888) - -## 0.13.1 (2020-12-12) - -### Fixed - -- Prevent exceptions when the ASGI application rejects a connection during the WebSocket handshake, when running on both `--ws wsproto` or `--ws websockets`. (#704 and #881) -- Ensure connection `scope` doesn't leak in logs when using JSON log formatters. (#859 and #884) - -## 0.13.0 (2020-12-08) - -### Added - -- Add `--factory` flag to support factory-style application imports. (#875) -- Skip installation of signal handlers when not in the main thread. Allows using `Server` in multithreaded contexts without having to override `.install_signal_handlers()`. (#871) - -## 0.12.3 (2020-11-21) - -### Fixed -- Fix race condition that leads Quart to hang with uvicorn (#848) -- Use latin1 when decoding X-Forwarded-* headers (#701) -- Rework IPv6 support (#837) -- Cancel old keepalive-trigger before setting new one. (#832) - -## 0.12.2 (2020-10-19) - -### Added -- Adding ability to decrypt ssl key file (#808) -- Support .yml log config files (#799) -- Added python 3.9 support (#804) - -### Fixed -- Fixes watchgod with common prefixes (#817) -- Fix reload with ipv6 host (#803) -- Added cli support for headers containing colon (#813) -- Sharing socket across workers on windows (#802) -- Note the need to configure trusted "ips" when using unix sockets (#796) - -## 0.12.1 (2020-09-30) - -### Changed -- Pinning h11 and python-dotenv to min versions (#789) -- Get docs/index.md in sync with README.md (#784) - -### Fixed -- Improve changelog by pointing out breaking changes (#792) - -## 0.12.0 (2020-09-28) - -### Added -- Make reload delay configurable (#774) -- Upgrade maximum h11 dependency version to 0.10 (#772) -- Allow .json or .yaml --log-config files (#665) -- Add ASGI dict to the lifespan scope (#754) -- Upgrade wsproto to 0.15.0 (#750) -- Use optional package installs (#666) - -### Changed -- Don't set log level for root logger (#767) 8/28/20 df81b168 -- Uvicorn no longer ships extra dependencies `uvloop`, `websockets` and `httptools` as default. - To install these dependencies use `uvicorn[standard]`. - -### Fixed -- Revert "Improve shutdown robustness when using `--reload` or multiprocessing (#620)" (#756) -- Fix terminate error in windows (#744) -- Fix bug where --log-config disables uvicorn loggers (#512) - -## 0.11.8 (2020-07-30) - -* Fix a regression that caused Uvicorn to crash when using `--interface=wsgi`. (#730) -* Fix a regression that caused Uvicorn to crash when using unix domain sockets. (#729) - -## 0.11.7 (2020-28-07) - -* SECURITY FIX: Prevent sending invalid HTTP header names and values. (#725) -* SECURITY FIX: Ensure path value is escaped before logging to the console. (#724) -* Fix `--proxy-headers` client IP and host when using a Unix socket. (#636) - -## 0.11.6 - -* Fix overriding the root logger. - -## 0.11.5 - -* Revert "Watch all files, not just .py" due to unexpected side effects. -* Revert "Pass through gunicorn timeout config." due to unexpected side effects. - -## 0.11.4 - -* Use `watchgod`, if installed, for watching code changes. -* Watch all files, not just .py. -* Pass through gunicorn timeout config. - -## 0.11.3 - -* Update dependencies. - -## 0.11.2 - -* Don't open socket until after application startup. -* Support `--backlog`. - -## 0.11.1 - -* Use a more liberal `h11` dependency. Either `0.8.*` or `0.9.*``. - -## 0.11.0 - -* Fix reload/multiprocessing on Windows with Python 3.8. -* Drop IOCP support. (Required for fix above.) -* Add `uvicorn --version` flag. -* Add `--use-colors` and `--no-use-colors` flags. -* Display port correctly, when auto port selection isused with `--port=0`. - -## 0.10.8 - -* Fix reload/multiprocessing error. - -## 0.10.7 - -* Use resource_sharer.DupSocket to resolve socket sharing on Windows. - -## 0.10.6 - -* Exit if `workers` or `reload` are use without an app import string style. -* Reorganise supervisor processes to properly hand over sockets on windows. - -## 0.10.5 - -* Update uvloop dependency to 0.14+ - -## 0.10.4 - -* Error clearly when `workers=` is used with app instance, instead of an app import string. -* Switch `--reload-dir` to current working directory by default. - -## 0.10.3 - -* Add ``--log-level trace` - -## 0.10.2 - -* Enable --proxy-headers by default. - -## 0.10.1 - -* Resolve issues with logging when using `--reload` or `--workers`. -* Setup up root logger to capture output for all logger instances, not just `uvicorn.error` and `uvicorn.access`. - -## 0.10.0 - -* Support for Python 3.8 -* Separated out `uvicorn.error` and `uvicorn.access` logs. -* Coloured log output when connected to a terminal. -* Dropped `logger=` config setting. -* Added `--log-config [FILE]` and `log_config=[str|dict]`. May either be a Python logging config dictionary or the file name of a logging configuration. -* Added `--forwarded_allow_ips` and `forwarded_allow_ips`. Defaults to the value of the `$FORWARDED_ALLOW_IPS` environment variable or "127.0.0.1". The `--proxy-headers` flag now defaults to `True`, but only trusted IPs are used to populate forwarding info. -* The `--workers` setting now defaults to the value of the `$WEB_CONCURRENCY` environment variable. -* Added support for `--env-file`. Requires `python-dotenv`. diff --git a/docs/deployment.md b/docs/deployment.md index 5fa2a43f5..a540e74d8 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -1,5 +1,3 @@ -# Deployment - Server deployment is a complex area, that will depend on what kind of service you're deploying Uvicorn onto. As a general rule, you probably want to: diff --git a/docs/overrides/partials/toc-item.html b/docs/overrides/partials/toc-item.html new file mode 100644 index 000000000..12f8e3d8c --- /dev/null +++ b/docs/overrides/partials/toc-item.html @@ -0,0 +1,18 @@ + +
  • + + + {{ toc_item.title }} + + + + +{% if toc_item.children %} + +{% endif %} + diff --git a/docs/release-notes.md b/docs/release-notes.md index 786b75d5a..001341cef 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1 +1,651 @@ ---8<-- "CHANGELOG.md" +--- +toc_depth: 2 +--- + +## 0.34.0 (December 15, 2024) + +### Added + +* Add `content-length` to 500 response in `wsproto` implementation (#2542) + +### Removed + +* Drop support for Python 3.8 (#2543) + +## 0.33.0 (December 14, 2024) + +### Removed + +* Remove `WatchGod` support for `--reload` (#2536) + +## 0.32.1 (November 20, 2024) + +### Fixed + +* Drop ASGI spec version to 2.3 on HTTP scope (#2513) +* Enable httptools lenient data on `httptools >= 0.6.3` (#2488) + +## 0.32.0 (October 15, 2024) + +### Added + +* Officially support Python 3.13 (#2482) +* Warn when `max_request_limit` is exceeded (#2430) + +## 0.31.1 (October 9, 2024) + +### Fixed + +* Support WebSockets 0.13.1 (#2471) +* Restore support for `[*]` in trusted hosts (#2480) +* Add `PathLike[str]` type hint for `ssl_keyfile` (#2481) + +## 0.31.0 (September 27, 2024) + +### Added + +Improve `ProxyHeadersMiddleware` (#2468) and (#2231): + +- Fix the host for requests from clients running on the proxy server itself. +- Fallback to host that was already set for empty x-forwarded-for headers. +- Also allow to specify IP Networks as trusted hosts. This greatly simplifies deployments + on docker swarm/kubernetes, where the reverse proxy might have a dynamic IP. + - This includes support for IPv6 Address/Networks. + +## 0.30.6 (August 13, 2024) + +### Fixed + +- Don't warn when upgrade is not WebSocket and depedencies are installed (#2360) + +## 0.30.5 (August 2, 2024) + +### Fixed + +- Don't close connection before receiving body on H11 (#2408) + +## 0.30.4 (July 31, 2024) + +### Fixed + +- Close connection when `h11` sets client state to `MUST_CLOSE` (#2375) + +## 0.30.3 (July 20, 2024) + +### Fixed + +- Suppress `KeyboardInterrupt` from CLI and programmatic usage (#2384) +- `ClientDisconnect` inherits from `OSError` instead of `IOError` (#2393) + +## 0.30.2 (July 20, 2024) + +### Added + +- Add `reason` support to [`websocket.disconnect`](https://asgi.readthedocs.io/en/latest/specs/www.html#disconnect-receive-event-ws) event (#2324) + +### Fixed + +- Iterate subprocesses in-place on the process manager (#2373) + +## 0.30.1 (June 2, 2024) + +### Fixed + +- Allow horizontal tabs `\t` in response header values (#2345) + +## 0.30.0 (May 28, 2024) + +### Added + +- New multiprocess manager (#2183) +- Allow `ConfigParser` or a `io.IO[Any]` on `log_config` (#1976) + +### Fixed + +- Suppress side-effects of signal propagation (#2317) +- Send `content-length` header on 5xx (#2304) + +### Deprecated + +- Deprecate the `uvicorn.workers` module (#2302) + +## 0.29.0 (March 19, 2024) + +### Added + +- Cooperative signal handling (#1600) + +## 0.28.1 (March 19, 2024) + +### Fixed + +- Revert raise `ClientDisconnected` on HTTP (#2276) + +## 0.28.0 (March 9, 2024) + +### Added + +- Raise `ClientDisconnected` on `send()` when client disconnected (#2220) + +### Fixed + +- Except `AttributeError` on `sys.stdin.fileno()` for Windows IIS10 (#1947) +- Use `X-Forwarded-Proto` for WebSockets scheme when the proxy provides it (#2258) + +## 0.27.1 (February 10, 2024) + +- Fix spurious LocalProtocolError errors when processing pipelined requests (#2243) + +## 0.27.0.post1 (January 29, 2024) + +### Fixed + +- Fix nav overrides for newer version of Mkdocs Material (#2233) + +## 0.27.0 (January 22, 2024) + +### Added + +- Raise `ClientDisconnect(IOError)` on `send()` when client disconnected (#2218) +- Bump ASGI WebSocket spec version to 2.4 (#2221) + +## 0.26.0 (January 16, 2024) + +### Changed + +- Update `--root-path` to include the root path prefix in the full ASGI `path` as per the ASGI spec (#2213) +- Use `__future__.annotations` on some internal modules (#2199) + +## 0.25.0 (December 17, 2023) + +### Added + +- Support the WebSocket Denial Response ASGI extension (#1916) + +### Fixed + +- Allow explicit hidden file paths on `--reload-include` (#2176) +- Properly annotate `uvicorn.run()` (#2158) + +## 0.24.0.post1 (November 6, 2023) + +### Fixed + +- Revert mkdocs-material from 9.1.21 to 9.2.6 (#2148) + +## 0.24.0 (November 4, 2023) + +### Added + +- Support Python 3.12 (#2145) +- Allow setting `app` via environment variable `UVICORN_APP` (#2106) + +## 0.23.2 (July 31, 2023) + +### Fixed + +- Maintain the same behavior of `websockets` from 10.4 on 11.0 (#2061) + +## 0.23.1 (July 18, 2023) + +### Fixed + +- Add `typing_extensions` for Python 3.10 and lower (#2053) + +## 0.23.0 (July 10, 2023) + +### Added + +- Add `--ws-max-queue` parameter WebSockets (#2033) + +### Removed + +- Drop support for Python 3.7 (#1996) +- Remove `asgiref` as typing dependency (#1999) + +### Fixed + +- Set `scope["scheme"]` to `ws` or `wss` instead of `http` or `https` on `ProxyHeadersMiddleware` for WebSockets (#2043) + +### Changed + +- Raise `ImportError` on circular import (#2040) +- Use `logger.getEffectiveLevel()` instead of `logger.level` to check if log level is `TRACE` (#1966) + +## 0.22.0 (April 28, 2023) + +### Added + +- Add `--timeout-graceful-shutdown` parameter (#1950) +- Handle `SIGBREAK` on Windows (#1909) + +### Fixed + +- Shutdown event is now being triggered on Windows when using hot reload (#1584) +- `--reload-delay` is effectively used on the `watchfiles` reloader (#1930) + +## 0.21.1 (March 16, 2023) + +### Fixed + +- Reset lifespan state on each request (#1903) + +## 0.21.0 (March 9, 2023) + +### Added + +- Introduce lifespan state (#1818) +- Allow headers to be sent as iterables on H11 implementation (#1782) +- Improve discoverability when --port=0 is used (#1890) + +### Changed + +- Avoid importing `h11` and `pyyaml` when not needed to improve import time (#1846) +- Replace current native `WSGIMiddleware` implementation by `a2wsgi` (#1825) +- Change default `--app-dir` from "." (dot) to "" (empty string) (#1835) + +### Fixed + +- Send code 1012 on shutdown for WebSockets (#1816) +- Use `surrogateescape` to encode headers on `websockets` implementation (#1005) +- Fix warning message on reload failure (#1784) + +## 0.20.0 (November 20, 2022) + +### Added + +- Check if handshake is completed before sending frame on `wsproto` shutdown (#1737) +- Add default headers to WebSockets implementations (#1606 & #1747) +- Warn user when `reload` and `workers` flag are used together (#1731) + +### Fixed + +- Use correct `WebSocket` error codes on `close` (#1753) +- Send disconnect event on connection lost for `wsproto` (#996) +- Add `SIGQUIT` handler to `UvicornWorker` (#1710) +- Fix crash on exist with "--uds" if socket doesn't exist (#1725) +- Annotate `CONFIG_KWARGS` in `UvicornWorker` class (#1746) + +### Removed + +- Remove conditional on `RemoteProtocolError.event_hint` on `wsproto` (#1486) +- Remove unused `handle_no_connect` on `wsproto` implementation (#1759) + +## 0.19.0 (October 19, 2022) + +### Added + +- Support Python 3.11 (#1652) +- Bump minimal `httptools` version to `0.5.0` (#1645) +- Ignore HTTP/2 upgrade and optionally ignore WebSocket upgrade (#1661) +- Add `py.typed` to comply with PEP 561 (#1687) + +### Fixed + +- Set `propagate` to `False` on "uvicorn" logger (#1288) +- USR1 signal is now handled correctly on `UvicornWorker`. (#1565) +- Use path with query string on `WebSockets` logs (#1385) +- Fix behavior on which "Date" headers were not updated on the same connection (#1706) + +### Removed + +- Remove the `--debug` flag (#1640) +- Remove the `DebugMiddleware` (#1697) + +## 0.18.3 (August 24, 2022) + +### Fixed + +- Remove cyclic references on HTTP implementations. (#1604) + +### Changed + +- `reload_delay` default changed from `None` to `0.25` on `uvicorn.run()` and `Config`. `None` is not an acceptable value anymore. (#1545) + +## 0.18.2 (June 27, 2022) + +### Fixed + +- Add default `log_config` on `uvicorn.run()` (#1541) +- Revert `logging` file name modification (#1543) + +## 0.18.1 (June 23, 2022) + +### Fixed + +- Use `DEFAULT_MAX_INCOMPLETE_EVENT_SIZE` as default to `h11_max_incomplete_event_size` on the CLI (#1534) + +## 0.18.0 (June 23, 2022) + +### Added + +- The `reload` flag prioritizes `watchfiles` instead of the deprecated `watchgod` (#1437) +- Annotate `uvicorn.run()` function (#1423) +- Allow configuring `max_incomplete_event_size` for `h11` implementation (#1514) + +### Removed + +- Remove `asgiref` dependency (#1532) + +### Fixed + +- Turn `raw_path` into bytes on both websockets implementations (#1487) +- Revert log exception traceback in case of invalid HTTP request (#1518) +- Set `asyncio.WindowsSelectorEventLoopPolicy()` when using multiple workers to avoid "WinError 87" (#1454) + +## 0.17.6 (March 11, 2022) + +### Changed + +- Change `httptools` range to `>=0.4.0` (#1400) + +## 0.17.5 (February 16, 2022) + +### Fixed + +- Fix case where url is fragmented in httptools protocol (#1263) +- Fix WSGI middleware not to explode quadratically in the case of a larger body (#1329) + +### Changed + +- Send HTTP 400 response for invalid request (#1352) + +## 0.17.4 (February 4, 2022) + +### Fixed + +- Replace `create_server` by `create_unix_server` (#1362) + +## 0.17.3 (February 3, 2022) + +### Fixed + +- Drop wsproto version checking. (#1359) + +## 0.17.2 (February 3, 2022) + +### Fixed + +- Revert #1332. While trying to solve the memory leak, it introduced an issue (#1345) when the server receives big chunks of data using the `httptools` implementation. (#1354) +- Revert stream interface changes. This was introduced on 0.14.0, and caused an issue (#1226), which caused a memory leak when sending TCP pings. (#1355) +- Fix wsproto version check expression (#1342) + +## 0.17.1 (January 28, 2022) + +### Fixed + +- Move all data handling logic to protocol and ensure connection is closed. (#1332) +- Change `spec_version` field from "2.1" to "2.3", as Uvicorn is compliant with that version of the ASGI specifications. (#1337) + +## 0.17.0.post1 (January 24, 2022) + +### Fixed + +- Add the `python_requires` version specifier (#1328) + +## 0.17.0 (January 14, 2022) + +### Added + +- Allow configurable websocket per-message-deflate setting (#1300) +- Support extra_headers for WS accept message (#1293) +- Add missing http version on websockets scope (#1309) + +### Fixed/Removed + +- Drop Python 3.6 support (#1261) +- Fix reload process behavior when exception is raised (#1313) +- Remove `root_path` from logs (#1294) + +## 0.16.0 (December 8, 2021) + +### Added + +- Enable read of uvicorn settings from environment variables (#1279) +- Bump `websockets` to 10.0. (#1180) +- Ensure non-zero exit code when startup fails (#1278) +- Increase `httptools` version range from "==0.2.*" to ">=0.2.0,<0.4.0". (#1243) +- Override default asyncio event loop with reload only on Windows (#1257) +- Replace `HttpToolsProtocol.pipeline` type from `list` to `deque`. (#1213) +- Replace `WSGIResponder.send_queue` type from `list` to `deque`. (#1214) + +### Fixed + +- Main process exit after startup failure on reloader classes (#1177) +- Fix the need of `httptools` on minimal installation (#1135) +- Fix ping parameters annotation in Config class (#1127) + +## 0.15.0 (August 13, 2021) + +### Added + +- Change reload to be configurable with glob patterns. Currently only `.py` files are watched, which is different from the previous default behavior. (#820) +- Add Python 3.10-rc.1 support. Now the server uses `asyncio.run` which will: start a fresh asyncio event loop, on shutdown cancel any background tasks rather than aborting them, `aexit` any remaining async generators, and shutdown the default `ThreadPoolExecutor`. (#1070) +- Exit with status 3 when worker starts failed (#1077) +- Add option to set websocket ping interval and timeout (#1048) +- Adapt bind_socket to make it usable with multiple processes (#1009) +- Add existence check to the reload directory(ies) (#1089) +- Add missing trace log for websocket protocols (#1083) +- Support disabling default Server and Date headers (#818) + +### Changed + +- Add PEP440 compliant version of click (#1099) +- Bump asgiref to 3.4.0 (#1100) + +### Fixed + +- When receiving a `SIGTERM` supervisors now terminate their processes before joining them (#1069) +- Fix `httptools` range to `>=0.4.0` (#1400) + +## 0.14.0 (June 1, 2021) + +### Added + +- Defaults ws max_size on server to 16MB (#995) +- Improve user feedback if no ws library installed (#926 and #1023) +- Support 'reason' field in 'websocket.close' messages (#957) +- Implemented lifespan.shutdown.failed (#755) + +### Changed + +- Upgraded websockets requirements (#1065) +- Switch to asyncio streams API (#869) +- Update httptools from 0.1.* to 0.2.* (#1024) +- Allow Click 8.0, refs #1016 (#1042) +- Add search for a trusted host in ProxyHeadersMiddleware (#591) +- Up wsproto to 1.0.0 (#892) + +### Fixed + +- Force reload_dirs to be a list (#978) +- Fix gunicorn worker not running if extras not installed (#901) +- Fix socket port 0 (#975) +- Prevent garbage collection of main lifespan task (#972) + +## 0.13.4 (February 20, 2021) + +### Fixed + +- Fixed wsgi middleware PATH_INFO encoding (#962) +- Fixed uvloop dependency (#952) then (#959) +- Relax watchgod up bound (#946) +- Return 'connection: close' header in response (#721) + +### Added + +- Docs: Nginx + websockets (#948) +- Document the default value of 1 for workers (#940) (#943) +- Enabled permessage-deflate extension in websockets (#764) + +## 0.13.3 (December 29, 2020) + +### Fixed + +- Prevent swallowing of return codes from `subprocess` when running with Gunicorn by properly resetting signals. (#895) +- Tweak detection of app factories to be more robust. A warning is now logged when passing a factory without the `--factory` flag. (#914) +- Properly clean tasks when handshake is aborted when running with `--ws websockets`. (#921) + +## 0.13.2 (December 12, 2020) + +### Fixed + +- Log full exception traceback in case of invalid HTTP request. (#886 and #888) + +## 0.13.1 (December 12, 2020) + +### Fixed + +- Prevent exceptions when the ASGI application rejects a connection during the WebSocket handshake, when running on both `--ws wsproto` or `--ws websockets`. (#704 and #881) +- Ensure connection `scope` doesn't leak in logs when using JSON log formatters. (#859 and #884) + +## 0.13.0 (December 8, 2020) + +### Added + +- Add `--factory` flag to support factory-style application imports. (#875) +- Skip installation of signal handlers when not in the main thread. Allows using `Server` in multithreaded contexts without having to override `.install_signal_handlers()`. (#871) + +## 0.12.3 (November 21, 2020) + +### Fixed +- Fix race condition that leads Quart to hang with uvicorn (#848) +- Use latin1 when decoding X-Forwarded-* headers (#701) +- Rework IPv6 support (#837) +- Cancel old keepalive-trigger before setting new one. (#832) + +## 0.12.2 (October 19, 2020) + +### Added +- Adding ability to decrypt ssl key file (#808) +- Support .yml log config files (#799) +- Added python 3.9 support (#804) + +### Fixed +- Fixes watchgod with common prefixes (#817) +- Fix reload with ipv6 host (#803) +- Added cli support for headers containing colon (#813) +- Sharing socket across workers on windows (#802) +- Note the need to configure trusted "ips" when using unix sockets (#796) + +## 0.12.1 (September 30, 2020) + +### Changed +- Pinning h11 and python-dotenv to min versions (#789) +- Get docs/index.md in sync with README.md (#784) + +### Fixed +- Improve changelog by pointing out breaking changes (#792) + +## 0.12.0 (September 28, 2020) + +### Added +- Make reload delay configurable (#774) +- Upgrade maximum h11 dependency version to 0.10 (#772) +- Allow .json or .yaml --log-config files (#665) +- Add ASGI dict to the lifespan scope (#754) +- Upgrade wsproto to 0.15.0 (#750) +- Use optional package installs (#666) + +### Changed +- Don't set log level for root logger (#767) 8/28/20 df81b168 +- Uvicorn no longer ships extra dependencies `uvloop`, `websockets` and `httptools` as default. + To install these dependencies use `uvicorn[standard]`. + +### Fixed +- Revert "Improve shutdown robustness when using `--reload` or multiprocessing (#620)" (#756) +- Fix terminate error in windows (#744) +- Fix bug where --log-config disables uvicorn loggers (#512) + +## 0.11.8 (July 30, 2020) + +* Fix a regression that caused Uvicorn to crash when using `--interface=wsgi`. (#730) +* Fix a regression that caused Uvicorn to crash when using unix domain sockets. (#729) + +## 0.11.7 (July 28, 2020) + +* SECURITY FIX: Prevent sending invalid HTTP header names and values. (#725) +* SECURITY FIX: Ensure path value is escaped before logging to the console. (#724) +* Fix `--proxy-headers` client IP and host when using a Unix socket. (#636) + +## 0.11.6 (July 17, 2020) + +* Fix overriding the root logger. + +## 0.11.5 (April 29, 2020) + +* Revert "Watch all files, not just .py" due to unexpected side effects. +* Revert "Pass through gunicorn timeout config." due to unexpected side effects. + +## 0.11.4 (April 28, 2020) + +* Use `watchgod`, if installed, for watching code changes. +* Watch all files, not just .py. +* Pass through gunicorn timeout config. + +## 0.11.3 (February 17, 2020) + +* Update dependencies. + +## 0.11.2 (January 20, 2020) + +* Don't open socket until after application startup. +* Support `--backlog`. + +## 0.11.1 (December 20, 2019) + +* Use a more liberal `h11` dependency. Either `0.8.*` or `0.9.*``. + +## 0.11.0 (December 20, 2019) + +* Fix reload/multiprocessing on Windows with Python 3.8. +* Drop IOCP support. (Required for fix above.) +* Add `uvicorn --version` flag. +* Add `--use-colors` and `--no-use-colors` flags. +* Display port correctly, when auto port selection isused with `--port=0`. + +## 0.10.8 (November 12, 2019) + +* Fix reload/multiprocessing error. + +## 0.10.7 (November 12, 2019) + +* Use resource_sharer.DupSocket to resolve socket sharing on Windows. + +## 0.10.6 (November 12, 2019) + +* Exit if `workers` or `reload` are use without an app import string style. +* Reorganise supervisor processes to properly hand over sockets on windows. + +## 0.10.5 (November 12, 2019) + +* Update uvloop dependency to 0.14+ + +## 0.10.4 (November 9, 2019) + +* Error clearly when `workers=` is used with app instance, instead of an app import string. +* Switch `--reload-dir` to current working directory by default. + +## 0.10.3 (November 1, 2019) + +* Add ``--log-level trace` + +## 0.10.2 (October 31, 2019) + +* Enable --proxy-headers by default. + +## 0.10.1 (October 31, 2019) + +* Resolve issues with logging when using `--reload` or `--workers`. +* Setup up root logger to capture output for all logger instances, not just `uvicorn.error` and `uvicorn.access`. + +## 0.10.0 (October 29, 2019) + +* Support for Python 3.8 +* Separated out `uvicorn.error` and `uvicorn.access` logs. +* Coloured log output when connected to a terminal. +* Dropped `logger=` config setting. +* Added `--log-config [FILE]` and `log_config=[str|dict]`. May either be a Python logging config dictionary or the file name of a logging configuration. +* Added `--forwarded_allow_ips` and `forwarded_allow_ips`. Defaults to the value of the `$FORWARDED_ALLOW_IPS` environment variable or "127.0.0.1". The `--proxy-headers` flag now defaults to `True`, but only trusted IPs are used to populate forwarding info. +* The `--workers` setting now defaults to the value of the `$WEB_CONCURRENCY` environment variable. +* Added support for `--env-file`. Requires `python-dotenv`. diff --git a/pyproject.toml b/pyproject.toml index 0a8996666..2883c690a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ standard = [ uvicorn = "uvicorn.main:main" [project.urls] -Changelog = "https://github.com/encode/uvicorn/blob/master/CHANGELOG.md" +Changelog = "https://www.uvicorn.org/release-notes" Funding = "https://github.com/sponsors/encode" Homepage = "https://www.uvicorn.org/" Source = "https://github.com/encode/uvicorn" diff --git a/scripts/sync-version b/scripts/sync-version index 025443820..a604862d6 100755 --- a/scripts/sync-version +++ b/scripts/sync-version @@ -1,7 +1,7 @@ #!/bin/sh -e SEMVER_REGEX="([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?" -CHANGELOG_VERSION=$(grep -o -E $SEMVER_REGEX CHANGELOG.md | head -1) +CHANGELOG_VERSION=$(grep -o -E $SEMVER_REGEX docs/release-notes.md | head -1) VERSION=$(grep -o -E $SEMVER_REGEX uvicorn/__init__.py | head -1) if [ "$CHANGELOG_VERSION" != "$VERSION" ]; then echo "Version in changelog does not match version in uvicorn/__init__.py!" From 90f43699c79bcd2b0676186fc6d3b9baf679d3c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 13:00:18 +0100 Subject: [PATCH 3/4] Bump the python-packages group with 6 updates (#2549) * Bump the python-packages group with 6 updates Bumps the python-packages group with 6 updates: | Package | From | To | | --- | --- | --- | | [websockets](https://github.com/python-websockets/websockets) | `13.1` | `14.1` | | [ruff](https://github.com/astral-sh/ruff) | `0.8.3` | `0.8.4` | | [mypy](https://github.com/python/mypy) | `1.13.0` | `1.14.1` | | [types-pyyaml](https://github.com/python/typeshed) | `6.0.12.20240917` | `6.0.12.20241230` | | [coverage](https://github.com/nedbat/coveragepy) | `7.6.9` | `7.6.10` | | [mkdocs-material](https://github.com/squidfunk/mkdocs-material) | `9.5.48` | `9.5.49` | Updates `websockets` from 13.1 to 14.1 - [Release notes](https://github.com/python-websockets/websockets/releases) - [Commits](https://github.com/python-websockets/websockets/compare/13.1...14.1) Updates `ruff` from 0.8.3 to 0.8.4 - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.8.3...0.8.4) Updates `mypy` from 1.13.0 to 1.14.1 - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.13.0...v1.14.1) Updates `types-pyyaml` from 6.0.12.20240917 to 6.0.12.20241230 - [Commits](https://github.com/python/typeshed/commits) Updates `coverage` from 7.6.9 to 7.6.10 - [Release notes](https://github.com/nedbat/coveragepy/releases) - [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst) - [Commits](https://github.com/nedbat/coveragepy/compare/7.6.9...7.6.10) Updates `mkdocs-material` from 9.5.48 to 9.5.49 - [Release notes](https://github.com/squidfunk/mkdocs-material/releases) - [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG) - [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.5.48...9.5.49) --- updated-dependencies: - dependency-name: websockets dependency-type: direct:production update-type: version-update:semver-major dependency-group: python-packages - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch dependency-group: python-packages - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor dependency-group: python-packages - dependency-name: types-pyyaml dependency-type: direct:production update-type: version-update:semver-patch dependency-group: python-packages - dependency-name: coverage dependency-type: direct:production update-type: version-update:semver-patch dependency-group: python-packages - dependency-name: mkdocs-material dependency-type: direct:production update-type: version-update:semver-patch dependency-group: python-packages ... Signed-off-by: dependabot[bot] * Update requirements.txt --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Marcelo Trylesinski --- requirements.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index e26e6b3c5..7b904aac4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,18 +14,18 @@ build==1.2.2.post1 twine==6.0.1 # Testing -ruff==0.8.3 +ruff==0.8.4 pytest==8.3.4 pytest-mock==3.14.0 -mypy==1.13.0 +mypy==1.14.1 types-click==7.1.8 -types-pyyaml==6.0.12.20240917 +types-pyyaml==6.0.12.20241230 trustme==1.2.0 cryptography==44.0.0 -coverage==7.6.9 +coverage==7.6.10 coverage-conditional-plugin==0.9.0 httpx==0.28.1 # Documentation mkdocs==1.6.1 -mkdocs-material==9.5.48 +mkdocs-material==9.5.49 From ae8253f10b9f73f10e92be52a0d9f70696b77c62 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Sat, 4 Jan 2025 10:58:27 +0100 Subject: [PATCH 4/4] Make CHANGELOG.md a symlink to release-notes.md (#2555) --- CHANGELOG.md | 1 + docs/plugins/main.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 120000 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 120000 index 000000000..9f024e93a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1 @@ +docs/release-notes.md \ No newline at end of file diff --git a/docs/plugins/main.py b/docs/plugins/main.py index ac7c1542e..b94acb9e9 100644 --- a/docs/plugins/main.py +++ b/docs/plugins/main.py @@ -33,7 +33,6 @@ def on_page_markdown(markdown: str, page: Page, config: Config, files: Files) -> def uvicorn_print_help(markdown: str, page: Page) -> str: # if you don't filter to the specific route that needs this substitution, things will be very slow - print(page.file.src_uri) if page.file.src_uri not in ("index.md", "deployment.md"): return markdown