Skip to main content

High-performance WSGI/ASGI server for Python, powered by Rust

Project description

🦄 Tsuno

High-performance WSGI/ASGI server powered by Rust

Python Version License Development Status

Tsuno aims to be a drop-in replacement for Gunicorn and Uvicorn with a Rust-powered transport layer. Run your Django, Flask, FastAPI, Starlette, and connect-python applications with HTTP/2 support.

Installation

pip install tsuno

Quick Start

Command Line

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
  • API Compatibility: Aims for complete compatibility with both Gunicorn and Uvicorn APIs
  • 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-3.14
  • Rust toolchain (for building from source)

Platform Support

  • macOS: Fully supported
  • Linux: Fully supported
  • Windows: Not tested yet

Known Limitations

Project Status: Alpha - production testing needed

Not Implemented Yet:

  • SSL/TLS support
  • CLI daemon mode (Python API supports it via daemon=True)
  • Custom worker_connections limits
  • Error log file redirection

Contributing

Contributions are welcome! Please:

  • Report issues at github.com/i2y/tsuno/issues
  • Submit pull requests for bug fixes or new features
  • Help improve documentation and examples

License

MIT License - see LICENSE

Links

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 Distribution

tsuno-0.1.3.tar.gz (63.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tsuno-0.1.3-cp311-abi3-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ x86-64

tsuno-0.1.3-cp311-abi3-manylinux_2_28_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

tsuno-0.1.3-cp311-abi3-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file tsuno-0.1.3.tar.gz.

File metadata

  • Download URL: tsuno-0.1.3.tar.gz
  • Upload date:
  • Size: 63.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tsuno-0.1.3.tar.gz
Algorithm Hash digest
SHA256 56973ea06ee0c852226bb18e80c497a84381d386c1c3f6aa57a2ed588053e003
MD5 901fbaf952c4bbd001d01d27f80fda87
BLAKE2b-256 a454ff4f2f1938ea37c01602d7075731efe97ef8eafd6ba24256d5bebccccc7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsuno-0.1.3.tar.gz:

Publisher: release.yml on i2y/tsuno

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tsuno-0.1.3-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tsuno-0.1.3-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 02747edc8cf628fc5c52877faa41c8c3c3f21611de02ebf2ed0afd7e4aca28d2
MD5 976e9e58a0be533271a06a8457d64855
BLAKE2b-256 64f20f64fe10aaabe5ab5c283070845dba38aa839bd07384b644e8737346c6de

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsuno-0.1.3-cp311-abi3-manylinux_2_28_x86_64.whl:

Publisher: release.yml on i2y/tsuno

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tsuno-0.1.3-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for tsuno-0.1.3-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e776cad79c02b68a055cbc5651bdcae7b4aae47fcc57a546607d3bff376f3654
MD5 707d1ac0bdd4e7ed5d48805bea6ab591
BLAKE2b-256 1ea70a19bb15d62130db8c085c758190fa195c45c553c5f23068bbb0b815cbaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsuno-0.1.3-cp311-abi3-manylinux_2_28_aarch64.whl:

Publisher: release.yml on i2y/tsuno

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tsuno-0.1.3-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tsuno-0.1.3-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d257f1e10f4b75765dd44336dea9ed7b8ee619472ec3f6aca7f7da88581dca41
MD5 a142c9345e7358276e096e957e68fda3
BLAKE2b-256 73983aa3bdaec9480949bb4f43cc5c3835d1ec661d0dfbfed74dfba658382499

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsuno-0.1.3-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on i2y/tsuno

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page