Skip to content

Commit

Permalink
Merge branch 'master' into fix/test_hang
Browse files Browse the repository at this point in the history
  • Loading branch information
vvanglro authored Dec 16, 2024
2 parents bd08e0e + 7983c1a commit 0956647
Show file tree
Hide file tree
Showing 23 changed files with 143 additions and 338 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
tests:
name: "Python ${{ matrix.python-version }} ${{ matrix.os }}"
runs-on: "${{ matrix.os }}"
timeout-minutes: 30
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: "actions/checkout@v4"
Expand All @@ -38,3 +38,14 @@ jobs:
- name: "Enforce coverage"
run: "scripts/coverage"
shell: bash

# https://github.com/marketplace/actions/alls-green#why
check:
if: always()
needs: [tests]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
# 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](https://github.com/encode/uvicorn/pull/2513)
* Enable httptools lenient data on `httptools >= 0.6.3` [#2488](https://github.com/encode/uvicorn/pull/2488)
* 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)

Expand Down
3 changes: 3 additions & 0 deletions docs/server-behavior.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ Server errors will be logged at the `error` log level. All logging defaults to b

If an exception is raised by an ASGI application, and a response has not yet been sent on the connection, then a `500 Server Error` HTTP response will be sent.

Uvicorn sends the headers and the status code as soon as it receives from the ASGI application. This means that if the application sends a [Response Start](https://asgi.readthedocs.io/en/latest/specs/www.html#response-start-send-event)
message with a status code of `200 OK`, and then an exception is raised, the response will still be sent with a status code of `200 OK`.

### Invalid responses

Uvicorn will ensure that ASGI applications send the correct sequence of messages, and will raise errors otherwise. This includes checking for no response sent, partial response sent, or invalid message sequences being sent.
Expand Down
8 changes: 6 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
site_name: Uvicorn
site_description: The lightning-fast ASGI server.
site_url: https://www.uvicorn.org

theme:
name: material
Expand All @@ -19,11 +20,14 @@ theme:
icon: "material/lightbulb-outline"
name: "Switch to light mode"
features:
- content.code.copy
- content.code.copy # https://squidfunk.github.io/mkdocs-material/upgrade/?h=content+copy#contentcodecopy
- navigation.top # https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/#back-to-top-button
- navigation.footer # https://squidfunk.github.io/mkdocs-material/upgrade/?h=content+copy#navigationfooter
- toc.follow # https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/#anchor-following

repo_name: encode/uvicorn
repo_url: https://github.com/encode/uvicorn
edit_uri: ""
edit_uri: edit/master/docs/

nav:
- Introduction: index.md
Expand Down
18 changes: 5 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ dynamic = ["version"]
description = "The lightning-fast ASGI server."
readme = "README.md"
license = "BSD-3-Clause"
requires-python = ">=3.8"
requires-python = ">=3.9"
authors = [
{ name = "Tom Christie", email = "[email protected]" },
{ name = "Marcelo Trylesinski", email = "[email protected]" }
{ name = "Marcelo Trylesinski", email = "[email protected]" },
]
classifiers = [
"Development Status :: 4 - Beta",
Expand All @@ -20,7 +20,6 @@ classifiers = [
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -38,7 +37,7 @@ dependencies = [

[project.optional-dependencies]
standard = [
"colorama>=0.4;sys_platform == 'win32'",
"colorama>=0.4; sys_platform == 'win32'",
"httptools>=0.6.3",
"python-dotenv>=0.13",
"PyYAML>=5.1",
Expand All @@ -60,11 +59,7 @@ Source = "https://github.com/encode/uvicorn"
path = "uvicorn/__init__.py"

[tool.hatch.build.targets.sdist]
include = [
"/uvicorn",
"/tests",
"/requirements.txt",
]
include = ["/uvicorn", "/tests", "/requirements.txt"]

[tool.ruff]
line-length = 120
Expand Down Expand Up @@ -94,10 +89,9 @@ addopts = "-rxXs --strict-config --strict-markers"
xfail_strict = true
filterwarnings = [
"error",
'ignore: \"watchgod\" is deprecated\, you should switch to watchfiles \(`pip install watchfiles`\)\.:DeprecationWarning',
"ignore:Uvicorn's native WSGI implementation is deprecated.*:DeprecationWarning",
"ignore: 'cgi' is deprecated and slated for removal in Python 3.13:DeprecationWarning",
"ignore: remove second argument of ws_handler:DeprecationWarning:websockets"
"ignore: remove second argument of ws_handler:DeprecationWarning:websockets",
]

[tool.coverage.run]
Expand Down Expand Up @@ -132,8 +126,6 @@ py-win32 = "sys_platform == 'win32'"
py-not-win32 = "sys_platform != 'win32'"
py-linux = "sys_platform == 'linux'"
py-darwin = "sys_platform == 'darwin'"
py-gte-38 = "sys_version_info >= (3, 8)"
py-lt-38 = "sys_version_info < (3, 8)"
py-gte-39 = "sys_version_info >= (3, 9)"
py-lt-39 = "sys_version_info < (3, 9)"
py-gte-310 = "sys_version_info >= (3, 10)"
Expand Down
18 changes: 8 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@ websockets==13.1

# Packaging
build==1.2.2.post1
twine==5.1.1
twine==6.0.1

# Testing
ruff==0.7.1
pytest==8.3.3
ruff==0.8.3
pytest==8.3.4
pytest-mock==3.14.0
mypy==1.13.0
types-click==7.1.8
types-pyyaml==6.0.12.20240917
trustme==1.1.0
cryptography==43.0.3
coverage==7.6.1; python_version < '3.9'
coverage==7.6.4; python_version >= '3.9'
trustme==1.2.0
cryptography==44.0.0
coverage==7.6.9
coverage-conditional-plugin==0.9.0
httpx==0.27.2
watchgod==0.8.2
httpx==0.28.1

# Documentation
mkdocs==1.6.1
mkdocs-material==9.5.43
mkdocs-material==9.5.48
23 changes: 0 additions & 23 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from hashlib import md5
from pathlib import Path
from tempfile import TemporaryDirectory
from threading import Thread
from time import sleep
from typing import Any
from uuid import uuid4

Expand Down Expand Up @@ -214,27 +212,6 @@ def make_tmp_dir(base_dir):
return


def sleep_touch(*paths: Path):
sleep(0.1)
for p in paths:
p.touch()


@pytest.fixture
def touch_soon():
threads = []

def start(*paths: Path):
thread = Thread(target=sleep_touch, args=paths)
thread.start()
threads.append(thread)

yield start

for t in threads:
t.join()


def _unused_port(socket_type: int) -> int:
"""Find an unused localhost port from 1024-65535 and return it."""
with contextlib.closing(socket.socket(type=socket_type)) as sock:
Expand Down
5 changes: 3 additions & 2 deletions tests/middleware/test_wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import io
import sys
from typing import AsyncGenerator, Callable
from collections.abc import AsyncGenerator
from typing import Callable

import a2wsgi
import httpx
Expand Down Expand Up @@ -72,7 +73,7 @@ async def test_wsgi_post(wsgi_middleware: Callable) -> None:
async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
response = await client.post("/", json={"example": 123})
assert response.status_code == 200
assert response.text == '{"example": 123}'
assert response.text == '{"example":123}'


@pytest.mark.anyio
Expand Down
Loading

0 comments on commit 0956647

Please sign in to comment.