tsuno 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tsuno-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Yasushi Itoh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
tsuno-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,246 @@
1
+ Metadata-Version: 2.4
2
+ Name: tsuno
3
+ Version: 0.1.1
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: License :: OSI Approved :: MIT License
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Programming Language :: Python :: 3.13
11
+ Classifier: Programming Language :: Python :: 3.14
12
+ Classifier: Programming Language :: Rust
13
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
+ Classifier: Topic :: Internet :: WWW/HTTP
15
+ Requires-Dist: watchfiles>=0.24.0
16
+ Requires-Dist: python-dotenv>=1.0.0
17
+ Requires-Dist: click>=8.0.0
18
+ Requires-Dist: uvloop>=0.21.0 ; python_full_version < '3.14' and platform_system != 'Windows' and extra == 'uvloop'
19
+ Provides-Extra: server
20
+ Provides-Extra: uvloop
21
+ License-File: LICENSE
22
+ Summary: High-performance WSGI/ASGI server for Python, powered by Rust
23
+ Keywords: wsgi,asgi,server,rust,async,http2,fastapi,flask,django,starlette,tsuno
24
+ Author-email: i2y <>
25
+ License-Expression: MIT
26
+ Requires-Python: >=3.11
27
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
28
+ Project-URL: Homepage, https://github.com/i2y/tsuno
29
+ Project-URL: Repository, https://github.com/i2y/tsuno
30
+ Project-URL: Issues, https://github.com/i2y/tsuno/issues
31
+
32
+ # 🦄 Tsuno
33
+
34
+ **High-performance WSGI/ASGI server powered by Rust**
35
+
36
+ ![Python Version](https://img.shields.io/badge/python-3.11+-blue.svg)
37
+ ![License](https://img.shields.io/badge/license-MIT-green.svg)
38
+ ![Development Status](https://img.shields.io/badge/status-alpha-orange.svg)
39
+
40
+ Tsuno aims to be a drop-in replacement for Gunicorn and Uvicorn with a Rust-powered transport layer. Run your [Django](https://www.djangoproject.com/), [Flask](https://flask.palletsprojects.com/), [FastAPI](https://fastapi.tiangolo.com/), [Starlette](https://www.starlette.io/), and [connect-python](https://github.com/connectrpc/connect-python) applications with HTTP/2 support.
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ pip install tsuno
46
+ ```
47
+
48
+ ## Quick Start
49
+
50
+ ### Command Line
51
+
52
+ ```bash
53
+ tsuno myapp:app --workers 4 --bind 0.0.0.0:8000
54
+ ```
55
+
56
+ ### Python API
57
+
58
+ **Flask (WSGI)**:
59
+ ```python
60
+ from flask import Flask
61
+ from tsuno import run
62
+
63
+ app = Flask(__name__)
64
+
65
+ @app.route("/")
66
+ def hello():
67
+ return "Hello World"
68
+
69
+ if __name__ == "__main__":
70
+ run(app)
71
+ ```
72
+
73
+ **FastAPI (ASGI)**:
74
+ ```python
75
+ from fastapi import FastAPI
76
+ from tsuno import run
77
+
78
+ app = FastAPI()
79
+
80
+ @app.get("/")
81
+ async def root():
82
+ return {"message": "Hello World"}
83
+
84
+ if __name__ == "__main__":
85
+ run(app)
86
+ ```
87
+
88
+ See [`examples/`](examples/) for complete working examples.
89
+
90
+ ## What Makes Tsuno Different
91
+
92
+ - **Mixed Protocol Serving**: Serve WSGI and ASGI apps simultaneously on the same server ([example](examples/mixed_wsgi_asgi.py))
93
+ - **High Performance**: Powered by Tokio and hyper
94
+ - **Complete API Compatibility**: Drop-in replacement for both Gunicorn AND Uvicorn as much as possible
95
+ - **Unix Domain Sockets**: Full UDS support for nginx integration ([example](examples/uds_example.py))
96
+
97
+ ## Examples
98
+
99
+ Complete working examples in the [`examples/`](examples/) directory:
100
+
101
+ | Example | Description |
102
+ |---------|-------------|
103
+ | **[wsgi_flask_app.py](examples/wsgi_flask_app.py)** | Flask WSGI application |
104
+ | **[asgi_fastapi_app.py](examples/asgi_fastapi_app.py)** | FastAPI ASGI application |
105
+ | **[mixed_wsgi_asgi.py](examples/mixed_wsgi_asgi.py)** | **Mixed WSGI + ASGI serving** (unique to Tsuno!) |
106
+ | **[wsgi_multi_app.py](examples/wsgi_multi_app.py)** | Multiple Flask apps on different paths |
107
+ | **[asgi_multi_app.py](examples/asgi_multi_app.py)** | Multiple FastAPI apps on different paths |
108
+ | **[uds_example.py](examples/uds_example.py)** | Unix Domain Socket server |
109
+ | **[lifespan_test.py](examples/lifespan_test.py)** | ASGI Lifespan events demo |
110
+ | **[tsuno.toml](examples/tsuno.toml)** | TOML configuration example |
111
+
112
+ ## Configuration
113
+
114
+ ### Command Line
115
+
116
+ ```bash
117
+ # Basic
118
+ tsuno myapp:app --bind 0.0.0.0:8000 --workers 4
119
+
120
+ # With auto-reload (development)
121
+ tsuno myapp:app --reload
122
+
123
+ # With Unix domain socket
124
+ tsuno myapp:app --uds /tmp/tsuno.sock
125
+
126
+ # With configuration file
127
+ tsuno myapp:app -c tsuno.toml
128
+ ```
129
+
130
+ ### Configuration File
131
+
132
+ **Python format** (Gunicorn-compatible):
133
+ ```python
134
+ # tsuno.conf.py
135
+ bind = "0.0.0.0:8000"
136
+ workers = 4
137
+ threads = 2
138
+ log_level = "info"
139
+ ```
140
+
141
+ **TOML format**:
142
+ ```toml
143
+ # tsuno.toml
144
+ bind = "0.0.0.0:8000"
145
+ workers = 4
146
+ threads = 2
147
+ log_level = "info"
148
+ ```
149
+
150
+ See [examples/tsuno.toml](examples/tsuno.toml) for all options.
151
+
152
+ ### Python API
153
+
154
+ ```python
155
+ from tsuno import run
156
+
157
+ run(
158
+ app,
159
+ host="0.0.0.0",
160
+ port=8000,
161
+ workers=4,
162
+ reload=True, # Development only
163
+ )
164
+ ```
165
+
166
+ ## Production Features
167
+
168
+ ### Worker Management
169
+ - Auto-restart crashed workers
170
+ - Graceful shutdown and reload
171
+ - Worker timeout monitoring
172
+ - Max requests per worker (memory leak prevention)
173
+
174
+ ### Graceful Reload (Zero-Downtime)
175
+
176
+ ```bash
177
+ # Start with PID file
178
+ tsuno myapp:app --pid /var/run/tsuno.pid
179
+
180
+ # Graceful reload (no downtime)
181
+ kill -HUP $(cat /var/run/tsuno.pid)
182
+ ```
183
+
184
+ ### Logging
185
+ - Structured logging (text/JSON)
186
+ - Access log support
187
+ - Customizable log formats
188
+
189
+ ## Performance
190
+
191
+ Performance varies by workload, platform, and configuration.
192
+ Run `wrk` or `h2load` benchmarks to measure performance on your specific hardware.
193
+
194
+ ## Migration
195
+
196
+ ### From Gunicorn
197
+
198
+ ```bash
199
+ # Before
200
+ gunicorn myapp:app --workers 4 --bind 0.0.0.0:8000
201
+
202
+ # After (same syntax!)
203
+ tsuno myapp:app --workers 4 --bind 0.0.0.0:8000
204
+ ```
205
+
206
+ ### From Uvicorn
207
+
208
+ ```python
209
+ # Before
210
+ import uvicorn
211
+ uvicorn.run(app, host="0.0.0.0", port=8000, workers=4)
212
+
213
+ # After (compatible API!)
214
+ import tsuno
215
+ tsuno.run(app, host="0.0.0.0", port=8000, workers=4)
216
+ ```
217
+
218
+ ## Development Status
219
+
220
+ **Tsuno is in early development (alpha stage)**.
221
+
222
+ - ⚠️ Real-world production testing needed
223
+
224
+ **Help us test!** Report issues at [github.com/i2y/tsuno/issues](https://github.com/i2y/tsuno/issues)
225
+
226
+ ## Requirements
227
+
228
+ - Python 3.11 or later
229
+ - Rust toolchain (for building from source)
230
+
231
+ ## License
232
+
233
+ MIT License - see [LICENSE](LICENSE)
234
+
235
+ ## Links
236
+
237
+ - **Repository**: [github.com/i2y/tsuno](https://github.com/i2y/tsuno)
238
+ - **Issues**: [github.com/i2y/tsuno/issues](https://github.com/i2y/tsuno/issues)
239
+
240
+ ## Acknowledgments
241
+
242
+ Tsuno is inspired by and builds upon excellent work from:
243
+ - **Gunicorn** & **Uvicorn**: Server standards
244
+ - **Granian**: Rust-Python hybrid architecture
245
+ - **Tokio**, **hyper**, **PyO3**: Rust ecosystem
246
+
tsuno-0.1.1/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # 🦄 Tsuno
2
+
3
+ **High-performance WSGI/ASGI server powered by Rust**
4
+
5
+ ![Python Version](https://img.shields.io/badge/python-3.11+-blue.svg)
6
+ ![License](https://img.shields.io/badge/license-MIT-green.svg)
7
+ ![Development Status](https://img.shields.io/badge/status-alpha-orange.svg)
8
+
9
+ Tsuno aims to be a drop-in replacement for Gunicorn and Uvicorn with a Rust-powered transport layer. Run your [Django](https://www.djangoproject.com/), [Flask](https://flask.palletsprojects.com/), [FastAPI](https://fastapi.tiangolo.com/), [Starlette](https://www.starlette.io/), and [connect-python](https://github.com/connectrpc/connect-python) applications with HTTP/2 support.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pip install tsuno
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ### Command Line
20
+
21
+ ```bash
22
+ tsuno myapp:app --workers 4 --bind 0.0.0.0:8000
23
+ ```
24
+
25
+ ### Python API
26
+
27
+ **Flask (WSGI)**:
28
+ ```python
29
+ from flask import Flask
30
+ from tsuno import run
31
+
32
+ app = Flask(__name__)
33
+
34
+ @app.route("/")
35
+ def hello():
36
+ return "Hello World"
37
+
38
+ if __name__ == "__main__":
39
+ run(app)
40
+ ```
41
+
42
+ **FastAPI (ASGI)**:
43
+ ```python
44
+ from fastapi import FastAPI
45
+ from tsuno import run
46
+
47
+ app = FastAPI()
48
+
49
+ @app.get("/")
50
+ async def root():
51
+ return {"message": "Hello World"}
52
+
53
+ if __name__ == "__main__":
54
+ run(app)
55
+ ```
56
+
57
+ See [`examples/`](examples/) for complete working examples.
58
+
59
+ ## What Makes Tsuno Different
60
+
61
+ - **Mixed Protocol Serving**: Serve WSGI and ASGI apps simultaneously on the same server ([example](examples/mixed_wsgi_asgi.py))
62
+ - **High Performance**: Powered by Tokio and hyper
63
+ - **Complete API Compatibility**: Drop-in replacement for both Gunicorn AND Uvicorn as much as possible
64
+ - **Unix Domain Sockets**: Full UDS support for nginx integration ([example](examples/uds_example.py))
65
+
66
+ ## Examples
67
+
68
+ Complete working examples in the [`examples/`](examples/) directory:
69
+
70
+ | Example | Description |
71
+ |---------|-------------|
72
+ | **[wsgi_flask_app.py](examples/wsgi_flask_app.py)** | Flask WSGI application |
73
+ | **[asgi_fastapi_app.py](examples/asgi_fastapi_app.py)** | FastAPI ASGI application |
74
+ | **[mixed_wsgi_asgi.py](examples/mixed_wsgi_asgi.py)** | **Mixed WSGI + ASGI serving** (unique to Tsuno!) |
75
+ | **[wsgi_multi_app.py](examples/wsgi_multi_app.py)** | Multiple Flask apps on different paths |
76
+ | **[asgi_multi_app.py](examples/asgi_multi_app.py)** | Multiple FastAPI apps on different paths |
77
+ | **[uds_example.py](examples/uds_example.py)** | Unix Domain Socket server |
78
+ | **[lifespan_test.py](examples/lifespan_test.py)** | ASGI Lifespan events demo |
79
+ | **[tsuno.toml](examples/tsuno.toml)** | TOML configuration example |
80
+
81
+ ## Configuration
82
+
83
+ ### Command Line
84
+
85
+ ```bash
86
+ # Basic
87
+ tsuno myapp:app --bind 0.0.0.0:8000 --workers 4
88
+
89
+ # With auto-reload (development)
90
+ tsuno myapp:app --reload
91
+
92
+ # With Unix domain socket
93
+ tsuno myapp:app --uds /tmp/tsuno.sock
94
+
95
+ # With configuration file
96
+ tsuno myapp:app -c tsuno.toml
97
+ ```
98
+
99
+ ### Configuration File
100
+
101
+ **Python format** (Gunicorn-compatible):
102
+ ```python
103
+ # tsuno.conf.py
104
+ bind = "0.0.0.0:8000"
105
+ workers = 4
106
+ threads = 2
107
+ log_level = "info"
108
+ ```
109
+
110
+ **TOML format**:
111
+ ```toml
112
+ # tsuno.toml
113
+ bind = "0.0.0.0:8000"
114
+ workers = 4
115
+ threads = 2
116
+ log_level = "info"
117
+ ```
118
+
119
+ See [examples/tsuno.toml](examples/tsuno.toml) for all options.
120
+
121
+ ### Python API
122
+
123
+ ```python
124
+ from tsuno import run
125
+
126
+ run(
127
+ app,
128
+ host="0.0.0.0",
129
+ port=8000,
130
+ workers=4,
131
+ reload=True, # Development only
132
+ )
133
+ ```
134
+
135
+ ## Production Features
136
+
137
+ ### Worker Management
138
+ - Auto-restart crashed workers
139
+ - Graceful shutdown and reload
140
+ - Worker timeout monitoring
141
+ - Max requests per worker (memory leak prevention)
142
+
143
+ ### Graceful Reload (Zero-Downtime)
144
+
145
+ ```bash
146
+ # Start with PID file
147
+ tsuno myapp:app --pid /var/run/tsuno.pid
148
+
149
+ # Graceful reload (no downtime)
150
+ kill -HUP $(cat /var/run/tsuno.pid)
151
+ ```
152
+
153
+ ### Logging
154
+ - Structured logging (text/JSON)
155
+ - Access log support
156
+ - Customizable log formats
157
+
158
+ ## Performance
159
+
160
+ Performance varies by workload, platform, and configuration.
161
+ Run `wrk` or `h2load` benchmarks to measure performance on your specific hardware.
162
+
163
+ ## Migration
164
+
165
+ ### From Gunicorn
166
+
167
+ ```bash
168
+ # Before
169
+ gunicorn myapp:app --workers 4 --bind 0.0.0.0:8000
170
+
171
+ # After (same syntax!)
172
+ tsuno myapp:app --workers 4 --bind 0.0.0.0:8000
173
+ ```
174
+
175
+ ### From Uvicorn
176
+
177
+ ```python
178
+ # Before
179
+ import uvicorn
180
+ uvicorn.run(app, host="0.0.0.0", port=8000, workers=4)
181
+
182
+ # After (compatible API!)
183
+ import tsuno
184
+ tsuno.run(app, host="0.0.0.0", port=8000, workers=4)
185
+ ```
186
+
187
+ ## Development Status
188
+
189
+ **Tsuno is in early development (alpha stage)**.
190
+
191
+ - ⚠️ Real-world production testing needed
192
+
193
+ **Help us test!** Report issues at [github.com/i2y/tsuno/issues](https://github.com/i2y/tsuno/issues)
194
+
195
+ ## Requirements
196
+
197
+ - Python 3.11 or later
198
+ - Rust toolchain (for building from source)
199
+
200
+ ## License
201
+
202
+ MIT License - see [LICENSE](LICENSE)
203
+
204
+ ## Links
205
+
206
+ - **Repository**: [github.com/i2y/tsuno](https://github.com/i2y/tsuno)
207
+ - **Issues**: [github.com/i2y/tsuno/issues](https://github.com/i2y/tsuno/issues)
208
+
209
+ ## Acknowledgments
210
+
211
+ Tsuno is inspired by and builds upon excellent work from:
212
+ - **Gunicorn** & **Uvicorn**: Server standards
213
+ - **Granian**: Rust-Python hybrid architecture
214
+ - **Tokio**, **hyper**, **PyO3**: Rust ecosystem