Skip to content

Commit

Permalink
Merge branch 'master' into feat/error-msg-on-multiprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex authored Dec 3, 2023
2 parents 711f4a3 + 2c55f20 commit 6ca58f9
Show file tree
Hide file tree
Showing 41 changed files with 634 additions and 360 deletions.
16 changes: 0 additions & 16 deletions .github/ISSUE_TEMPLATE/1-issue.md

This file was deleted.

68 changes: 68 additions & 0 deletions .github/ISSUE_TEMPLATE/1-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Issue
description: Report a bug or unexpected behavior. 🙏

body:
- type: markdown
attributes:
value: Thank you for contributing to Uvicorn! ✊

- type: checkboxes
id: checks
attributes:
label: Initial Checks
description: Just making sure you open a discussion first. 🙏
options:
- label: I confirm this was discussed, and the maintainers suggest I open an issue.
required: true
- label: I'm aware that if I created this issue without a discussion, it may be closed without a response.
required: true

- type: textarea
id: discussion
attributes:
label: Discussion Link
description: |
Please link to the discussion that led to this issue.
If you haven't discussed this issue yet, please do so before opening an issue.
render: Text
validations:
required: true

- type: textarea
id: description
attributes:
label: Description
description: |
Please explain what you're seeing and what you would expect to see.
Please provide as much detail as possible to make understanding and solving your problem as quick as possible. 🙏
validations:
required: true

- type: textarea
id: example
attributes:
label: Example Code
description: >
If applicable, please add a self-contained,
[minimal, reproducible, example](https://stackoverflow.com/help/minimal-reproducible-example)
demonstrating the bug.
render: Python

- type: textarea
id: version
attributes:
label: Python, Uvicorn & OS Version
description: |
Which version of Python & Uvicorn are you using, and which Operating System?
Please run the following command and copy the output below:
```bash
python -m uvicorn --version
```
render: Text
validations:
required: true
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
name: deploy

steps:
- uses: "actions/checkout@v3"
- uses: "actions/checkout@v4"
- uses: "actions/setup-python@v4"
with:
python-version: 3.7
python-version: "3.8"
- name: "Install dependencies"
run: "scripts/install"
- name: "Build package & docs"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: "${{ matrix.os }}"
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: "actions/checkout@v3"
- uses: "actions/checkout@v4"
- uses: "actions/setup-python@v4"
with:
python-version: "${{ matrix.python-version }}"
Expand Down
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# Change Log

## 0.24.0.post1 - 2023-11-06

### Fixed

* Revert mkdocs-material from 9.1.21 to 9.2.6 (#2148) 05/11/23

## 0.24.0 - 2023-11-04

### Added

- Support Python 3.12 (#2145) 04/11/23
- Allow setting `app` via environment variable `UVICORN_APP` (#2106) 21/09/23

## 0.23.2 - 2023-07-31

### Fixed

- Maintain the same behavior of `websockets` from 10.4 on 11.0 (#2061) 30/07/23

## 0.23.1 - 2023-07-18

### Fixed

- Add `typing_extensions` for Python 3.10 and lower (#2053) 18/07/23

## 0.23.0 - 2023-07-10

### Added

- Add `--ws-max-queue` parameter WebSockets (#2033) 10/07/23

### Removed

- Drop support for Python 3.7 (#1996) 19/06/23
- Remove `asgiref` as typing dependency (#1999) 08/06/23

### Fixed

- Set `scope["scheme"]` to `ws` or `wss` instead of `http` or `https` on `ProxyHeadersMiddleware` for WebSockets (#2043) 12/07/23

### Changed

- Raise `ImportError` on circular import (#2040) 09/07/23
- Use `logger.getEffectiveLevel()` instead of `logger.level` to check if log level is `TRACE` (#1966) 01/06/23

## 0.22.0 - 2023-04-28

### Added
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@

[![Build Status](https://github.com/encode/uvicorn/workflows/Test%20Suite/badge.svg)](https://github.com/encode/uvicorn/actions)
[![Package version](https://badge.fury.io/py/uvicorn.svg)](https://pypi.python.org/pypi/uvicorn)
[![Supported Python Version](https://img.shields.io/pypi/pyversions/uvicorn.svg?color=%2334D058)](https://pypi.org/project/uvicorn)

**Documentation**: [https://www.uvicorn.org](https://www.uvicorn.org)

**Requirements**: Python 3.7+ (For Python 3.6 support, install version 0.16.0.)
**Requirements**: Python 3.8+

Uvicorn is an ASGI web server implementation for Python.

Expand Down
34 changes: 17 additions & 17 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ As a general rule, you probably want to:
Typically you'll run `uvicorn` from the command line.

```bash
$ uvicorn example:app --reload --port 5000
$ uvicorn main:app --reload --port 5000
```

The ASGI application should be specified in the form `path.to.module:instance.path`.
Expand Down Expand Up @@ -65,8 +65,12 @@ Options:
[default: auto]
--ws-max-size INTEGER WebSocket max size message in bytes
[default: 16777216]
--ws-ping-interval FLOAT WebSocket ping interval [default: 20.0]
--ws-ping-timeout FLOAT WebSocket ping timeout [default: 20.0]
--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]
Expand Down Expand Up @@ -139,9 +143,7 @@ See the [settings documentation](settings.md) for more details on the supported

To run directly from within a Python program, you should use `uvicorn.run(app, **config)`. For example:

**example.py**:

```python
```py title="main.py"
import uvicorn

class App:
Expand All @@ -150,7 +152,7 @@ class App:
app = App()

if __name__ == "__main__":
uvicorn.run("example:app", host="127.0.0.1", port=5000, log_level="info")
uvicorn.run("main:app", host="127.0.0.1", port=5000, log_level="info")
```

The set of configuration options is the same as for the command line tool.
Expand Down Expand Up @@ -195,6 +197,8 @@ Gunicorn provides a different set of configuration options to Uvicorn, so some
If you need to pass uvicorn's config arguments to gunicorn workers then you'll have to subclass `UvicornWorker`:

```python
from uvicorn.workers import UvicornWorker

class MyUvicornWorker(UvicornWorker):
CONFIG_KWARGS = {"loop": "asyncio", "http": "h11", "lifespan": "off"}
```
Expand All @@ -208,14 +212,12 @@ To use `supervisor` as a process manager you should either:

A simple supervisor configuration might look something like this:

**supervisord.conf**:

```ini
```ini title="supervisord.conf"
[supervisord]

[fcgi-program:uvicorn]
socket=tcp://localhost:8000
command=venv/bin/uvicorn --fd 0 example:App
command=venv/bin/uvicorn --fd 0 main:App
numprocs=4
process_name=uvicorn-%(process_num)d
stdout_logfile=/dev/stdout
Expand All @@ -233,11 +235,9 @@ To use `circus` as a process manager, you should either:

A simple circus configuration might look something like this:

**circus.ini**:

```ini
```ini title="circus.ini"
[watcher:web]
cmd = venv/bin/uvicorn --fd $(circus.sockets.web) example:App
cmd = venv/bin/uvicorn --fd $(circus.sockets.web) main:App
use_sockets = True
numprocesses = 4

Expand Down Expand Up @@ -323,15 +323,15 @@ For local development with https, it's possible to use [mkcert][mkcert]
to generate a valid certificate and private key.

```bash
$ uvicorn example:app --port 5000 --ssl-keyfile=./key.pem --ssl-certfile=./cert.pem
$ uvicorn main:app --port 5000 --ssl-keyfile=./key.pem --ssl-certfile=./cert.pem
```

### Running gunicorn worker

It's also possible to use certificates with uvicorn's worker for gunicorn.

```bash
$ gunicorn --keyfile=./key.pem --certfile=./cert.pem -k uvicorn.workers.UvicornWorker example:app
$ gunicorn --keyfile=./key.pem --certfile=./cert.pem -k uvicorn.workers.UvicornWorker main:app
```

[nginx_websocket]: https://nginx.org/en/docs/http/websocket.html
Expand Down
Loading

0 comments on commit 6ca58f9

Please sign in to comment.