Gunicorn 24.0 has been released! #3446
Replies: 5 comments 3 replies
-
Beta Was this translation helpful? Give feedback.
-
|
Great news! The new docs look great. I noticed the "Documentation" and "Changelog" links on the PyPI sidebar still point to |
Beta Was this translation helpful? Give feedback.
-
|
Hello, are the lifespan hooks designed to run once per worker? I am running into the same situation with Hypercorn + Quart right now. from asyncio import sleep
from quart import Quart
app = Quart(__name__)
@app.route('/')
async def hello():
return 'hello'
@app.before_serving
async def on_start():
await sleep(0.01)
print('Wish to only print once, on start')
@app.after_serving
async def on_end():
await sleep(0.01)
print('Wish to only print once, on end') |
Beta Was this translation helpful? Give feedback.
-
|
The current behavior is correct per the ASGI Lifespan Protocol specification:
With 4 workers, you get 4 separate processes, each with its own event loop and application instance. Running lifespan once per worker ensures resources like database connections are properly initialized in each process. For operations that should run only once globally, use gunicorn's server-level hooks: # gunicorn.conf.py
def when_ready(server):
print("Runs once in master, before workers spawn") |
Beta Was this translation helpful? Give feedback.
-
|
To add more context, gunicorn provides hooks at different levels: Global (master process): Per-worker: ASGI lifespan Per-request: Example: # gunicorn.conf.py
def when_ready(server):
# Runs once in master process
print("Server ready!")
def pre_request(worker, req):
# Runs before each request
worker.log.debug("%s %s", req.method, req.path)
def post_request(worker, req, environ, resp):
# Runs after each request
passThe per-request hooks work with all worker types including the ASGI worker. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Highlights
ASGI Worker (Beta)
Gunicorn now includes native asyncio-based ASGI support for running async Python frameworks like FastAPI, Starlette, and Quart — without external dependencies.
Features:
New settings: --asgi-loop, --asgi-lifespan, --root-path
uWSGI Binary Protocol
Support for receiving requests from nginx via uwsgi_pass directive:
New settings: --protocol uwsgi, --uwsgi-allow-from
Documentation
Migrated to MkDocs with Material theme for improved navigation and mobile experience at https://gunicorn.org
Security Updates
Updated minimum versions for async workers to address known vulnerabilities:
Install
pip install --upgrade gunicorn
Links
Beta Was this translation helpful? Give feedback.
All reactions