Skip to content

Commit

Permalink
Merge branch 'master' into feature/timeout_worker_is_alive
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex authored Nov 20, 2024
2 parents e5e5d1e + 6215230 commit bf05fe4
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 31 deletions.
88 changes: 72 additions & 16 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,80 @@ on:
- '*'

jobs:
publish:
name: "Publish release"
runs-on: "ubuntu-latest"
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: scripts/install

- name: Build package & docs
run: scripts/build

- name: Upload package distributions
uses: actions/upload-artifact@v4
with:
name: package-distributions
path: dist/

- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: documentation
path: site/

pypi-publish:
runs-on: ubuntu-latest
needs: build

permissions:
id-token: write

environment:
name: deploy
name: pypi
url: https://pypi.org/project/uvicorn

steps:
- uses: "actions/checkout@v4"
- uses: "actions/setup-python@v5"
- name: Download artifacts
uses: actions/download-artifact@v4
with:
python-version: "3.8"
- name: "Install dependencies"
run: "scripts/install"
- name: "Build package & docs"
run: "scripts/build"
- name: "Publish to PyPI & deploy docs"
run: "scripts/publish"
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
name: package-distributions
path: dist/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

docs-publish:
runs-on: ubuntu-latest
needs: build

permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: documentation
path: site/

- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: scripts/install

- name: Publish documentation 📚 to GitHub Pages
run: mkdocs gh-deploy --force
1 change: 1 addition & 0 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
runs-on: "${{ matrix.os }}"
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
os: [windows-latest, ubuntu-latest, macos-latest]
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## 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)

## 0.32.0 (2024-10-15)

### Added
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies = [
[project.optional-dependencies]
standard = [
"colorama>=0.4;sys_platform == 'win32'",
"httptools>=0.5.0",
"httptools>=0.6.3",
"python-dotenv>=0.13",
"PyYAML>=5.1",
"uvloop>=0.14.0,!=0.15.0,!=0.15.1; sys_platform != 'win32' and (sys_platform != 'cygwin' and platform_python_implementation != 'PyPy')",
Expand Down
13 changes: 7 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@ wsproto==1.2.0
websockets==13.1

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

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

# Documentation
mkdocs==1.6.1
mkdocs-material==9.5.39
mkdocs-material==9.5.43
4 changes: 2 additions & 2 deletions tests/protocols/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,8 @@ async def asgi(receive: ASGIReceiveCallable, send: ASGISendCallable):
@pytest.mark.parametrize(
"asgi2or3_app, expected_scopes",
[
(asgi3app, {"version": "3.0", "spec_version": "2.4"}),
(asgi2app, {"version": "2.0", "spec_version": "2.4"}),
(asgi3app, {"version": "3.0", "spec_version": "2.3"}),
(asgi2app, {"version": "2.0", "spec_version": "2.3"}),
],
)
async def test_scopes(
Expand Down
2 changes: 1 addition & 1 deletion uvicorn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from uvicorn.config import Config
from uvicorn.main import Server, main, run

__version__ = "0.32.0"
__version__ = "0.32.1"
__all__ = ["main", "run", "Config", "Server"]
5 changes: 1 addition & 4 deletions uvicorn/protocols/http/h11_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,7 @@ def handle_events(self) -> None:
full_raw_path = self.root_path.encode("ascii") + raw_path
self.scope = {
"type": "http",
"asgi": {
"version": self.config.asgi_version,
"spec_version": "2.4",
},
"asgi": {"version": self.config.asgi_version, "spec_version": "2.3"},
"http_version": event.http_version.decode("ascii"),
"server": self.server,
"client": self.client,
Expand Down
10 changes: 9 additions & 1 deletion uvicorn/protocols/http/httptools_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ def __init__(
self.access_logger = logging.getLogger("uvicorn.access")
self.access_log = self.access_logger.hasHandlers()
self.parser = httptools.HttpRequestParser(self)

try:
# Enable dangerous leniencies to allow server to a response on the first request from a pipelined request.
self.parser.set_dangerous_leniencies(lenient_data_after_close=True)
except AttributeError: # pragma: no cover
# httptools < 0.6.3
pass

self.ws_protocol_class = config.ws_protocol_class
self.root_path = config.root_path
self.limit_concurrency = config.limit_concurrency
Expand Down Expand Up @@ -214,7 +222,7 @@ def on_message_begin(self) -> None:
self.headers = []
self.scope = { # type: ignore[typeddict-item]
"type": "http",
"asgi": {"version": self.config.asgi_version, "spec_version": "2.4"},
"asgi": {"version": self.config.asgi_version, "spec_version": "2.3"},
"http_version": "1.1",
"server": self.server,
"client": self.client,
Expand Down

0 comments on commit bf05fe4

Please sign in to comment.