High-performance WSGI/ASGI server for Python, powered by Rust
Project description
Tsuno
High-performance WSGI/ASGI server powered by Rust
Tsuno aims to be a drop-in replacement for Gunicorn and Uvicorn with a Rust-powered transport layer. Run your Django, Flask, FastAPI, and Starlette applications with HTTP/2 support.
Installation
pip install tsuno
Quick Start
Command Line
# Replace Gunicorn/Uvicorn
tsuno myapp:app --workers 4 --bind 0.0.0.0:8000
Python API
Flask (WSGI):
from flask import Flask
from tsuno import run
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World"
if __name__ == "__main__":
run(app)
FastAPI (ASGI):
from fastapi import FastAPI
from tsuno import run
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
if __name__ == "__main__":
run(app)
See examples/ for complete working examples.
What Makes Tsuno Different
- Mixed Protocol Serving: Serve WSGI and ASGI apps simultaneously on the same server (example)
- High Performance: Powered by Tokio and hyper
- Complete API Compatibility: Drop-in replacement for both Gunicorn AND Uvicorn as much as possible
- Unix Domain Sockets: Full UDS support for nginx integration (example)
Examples
Complete working examples in the examples/ directory:
| Example | Description |
|---|---|
| wsgi_flask_app.py | Flask WSGI application |
| asgi_fastapi_app.py | FastAPI ASGI application |
| mixed_wsgi_asgi.py | Mixed WSGI + ASGI serving (unique to Tsuno!) |
| wsgi_multi_app.py | Multiple Flask apps on different paths |
| asgi_multi_app.py | Multiple FastAPI apps on different paths |
| uds_example.py | Unix Domain Socket server |
| lifespan_test.py | ASGI Lifespan events demo |
| tsuno.toml | TOML configuration example |
Configuration
Command Line
# Basic
tsuno myapp:app --bind 0.0.0.0:8000 --workers 4
# With auto-reload (development)
tsuno myapp:app --reload
# With Unix domain socket
tsuno myapp:app --uds /tmp/tsuno.sock
# With configuration file
tsuno myapp:app -c tsuno.toml
Configuration File
Python format (Gunicorn-compatible):
# tsuno.conf.py
bind = "0.0.0.0:8000"
workers = 4
threads = 2
log_level = "info"
TOML format:
# tsuno.toml
bind = "0.0.0.0:8000"
workers = 4
threads = 2
log_level = "info"
See examples/tsuno.toml for all options.
Python API
from tsuno import run
run(
app,
host="0.0.0.0",
port=8000,
workers=4,
reload=True, # Development only
)
Production Features
Worker Management
- Auto-restart crashed workers
- Graceful shutdown and reload
- Worker timeout monitoring
- Max requests per worker (memory leak prevention)
Graceful Reload (Zero-Downtime)
# Start with PID file
tsuno myapp:app --pid /var/run/tsuno.pid
# Graceful reload (no downtime)
kill -HUP $(cat /var/run/tsuno.pid)
Logging
- Structured logging (text/JSON)
- Access log support
- Customizable log formats
Performance
Performance varies by workload, platform, and configuration.
Run wrk or h2load benchmarks to measure performance on your specific hardware.
Migration
From Gunicorn
# Before
gunicorn myapp:app --workers 4 --bind 0.0.0.0:8000
# After (same syntax!)
tsuno myapp:app --workers 4 --bind 0.0.0.0:8000
From Uvicorn
# Before
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000, workers=4)
# After (compatible API!)
import tsuno
tsuno.run(app, host="0.0.0.0", port=8000, workers=4)
Development Status
Tsuno is in early development (alpha stage).
- ⚠️ Real-world production testing needed
Help us test! Report issues at github.com/i2y/tsuno/issues
Requirements
- Python 3.11 or later
- Rust toolchain (for building from source)
License
MIT License - see LICENSE
Links
- Repository: github.com/i2y/tsuno
- Issues: github.com/i2y/tsuno/issues
Acknowledgments
Tsuno is inspired by and builds upon excellent work from:
- Gunicorn & Uvicorn: Server standards
- Granian: Rust-Python hybrid architecture
- Tokio, hyper, PyO3: Rust ecosystem
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tsuno-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: tsuno-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fc9424f236a998f7857618d6daf11989cfe358c963858e2ad3c0d5c993a686e
|
|
| MD5 |
8d927637b4e505cdbfdb359723dbb45d
|
|
| BLAKE2b-256 |
5b30c1ce14759bbe9bbfcefa1383df83ea4747859eef746b507347eaea147add
|
Provenance
The following attestation bundles were made for tsuno-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl:
Publisher:
release.yml on i2y/tsuno
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsuno-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
9fc9424f236a998f7857618d6daf11989cfe358c963858e2ad3c0d5c993a686e - Sigstore transparency entry: 625270335
- Sigstore integration time:
-
Permalink:
i2y/tsuno@9ffac83c7cf69f09b085a410bebd5ae499a1cd89 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/i2y
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9ffac83c7cf69f09b085a410bebd5ae499a1cd89 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tsuno-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: tsuno-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
805dc5dd69f6c17f31c69e41c1fd3e60dc7cfcfc3c4d5308f1f94b0b8f124734
|
|
| MD5 |
025b027817b20d5a1a56f411dccafdcc
|
|
| BLAKE2b-256 |
b226b866bc2924fd48b491ecaf5f22e26feb5b1509ae60c2b3ee3590dc6637aa
|
Provenance
The following attestation bundles were made for tsuno-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl:
Publisher:
release.yml on i2y/tsuno
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsuno-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl -
Subject digest:
805dc5dd69f6c17f31c69e41c1fd3e60dc7cfcfc3c4d5308f1f94b0b8f124734 - Sigstore transparency entry: 625270328
- Sigstore integration time:
-
Permalink:
i2y/tsuno@9ffac83c7cf69f09b085a410bebd5ae499a1cd89 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/i2y
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9ffac83c7cf69f09b085a410bebd5ae499a1cd89 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tsuno-0.1.0-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: tsuno-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
302460b338abb1a6bf876b18b6199631efe927f711880846616002196b60a605
|
|
| MD5 |
c4bf4d5e20bbd55a9b476d1107f0c241
|
|
| BLAKE2b-256 |
0ec732bed07206f6434fba266ea012a13d8029abe06597e787993f7876f267a5
|
Provenance
The following attestation bundles were made for tsuno-0.1.0-cp311-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on i2y/tsuno
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsuno-0.1.0-cp311-abi3-macosx_11_0_arm64.whl -
Subject digest:
302460b338abb1a6bf876b18b6199631efe927f711880846616002196b60a605 - Sigstore transparency entry: 625270342
- Sigstore integration time:
-
Permalink:
i2y/tsuno@9ffac83c7cf69f09b085a410bebd5ae499a1cd89 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/i2y
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9ffac83c7cf69f09b085a410bebd5ae499a1cd89 -
Trigger Event:
push
-
Statement type: