tasgi 0.1.0a1__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.
Files changed (50) hide show
  1. tasgi-0.1.0a1/LICENSE +183 -0
  2. tasgi-0.1.0a1/NOTICE +4 -0
  3. tasgi-0.1.0a1/PKG-INFO +506 -0
  4. tasgi-0.1.0a1/README.md +296 -0
  5. tasgi-0.1.0a1/pyproject.toml +40 -0
  6. tasgi-0.1.0a1/setup.cfg +4 -0
  7. tasgi-0.1.0a1/src/tasgi/__init__.py +66 -0
  8. tasgi-0.1.0a1/src/tasgi/app.py +696 -0
  9. tasgi-0.1.0a1/src/tasgi/asgi.py +57 -0
  10. tasgi-0.1.0a1/src/tasgi/asgi_server.py +1055 -0
  11. tasgi-0.1.0a1/src/tasgi/auth/__init__.py +24 -0
  12. tasgi-0.1.0a1/src/tasgi/auth/backends.py +180 -0
  13. tasgi-0.1.0a1/src/tasgi/auth/base.py +40 -0
  14. tasgi-0.1.0a1/src/tasgi/auth/exceptions.py +19 -0
  15. tasgi-0.1.0a1/src/tasgi/auth/models.py +40 -0
  16. tasgi-0.1.0a1/src/tasgi/auth/policies.py +46 -0
  17. tasgi-0.1.0a1/src/tasgi/config.py +62 -0
  18. tasgi-0.1.0a1/src/tasgi/dependencies.py +235 -0
  19. tasgi-0.1.0a1/src/tasgi/docs.py +399 -0
  20. tasgi-0.1.0a1/src/tasgi/exceptions.py +39 -0
  21. tasgi-0.1.0a1/src/tasgi/http2.py +553 -0
  22. tasgi-0.1.0a1/src/tasgi/http_parser.py +120 -0
  23. tasgi-0.1.0a1/src/tasgi/lifecycle.py +49 -0
  24. tasgi-0.1.0a1/src/tasgi/main.py +86 -0
  25. tasgi-0.1.0a1/src/tasgi/middleware.py +74 -0
  26. tasgi-0.1.0a1/src/tasgi/request.py +106 -0
  27. tasgi-0.1.0a1/src/tasgi/response.py +222 -0
  28. tasgi-0.1.0a1/src/tasgi/routing.py +677 -0
  29. tasgi-0.1.0a1/src/tasgi/runtime.py +108 -0
  30. tasgi-0.1.0a1/src/tasgi/schema.py +217 -0
  31. tasgi-0.1.0a1/src/tasgi/state.py +75 -0
  32. tasgi-0.1.0a1/src/tasgi/types.py +48 -0
  33. tasgi-0.1.0a1/src/tasgi/websocket.py +194 -0
  34. tasgi-0.1.0a1/src/tasgi/wsproto.py +163 -0
  35. tasgi-0.1.0a1/src/tasgi.egg-info/PKG-INFO +506 -0
  36. tasgi-0.1.0a1/src/tasgi.egg-info/SOURCES.txt +48 -0
  37. tasgi-0.1.0a1/src/tasgi.egg-info/dependency_links.txt +1 -0
  38. tasgi-0.1.0a1/src/tasgi.egg-info/entry_points.txt +2 -0
  39. tasgi-0.1.0a1/src/tasgi.egg-info/top_level.txt +1 -0
  40. tasgi-0.1.0a1/tests/test_app.py +387 -0
  41. tasgi-0.1.0a1/tests/test_asgi_runtime.py +244 -0
  42. tasgi-0.1.0a1/tests/test_auth.py +167 -0
  43. tasgi-0.1.0a1/tests/test_errors.py +82 -0
  44. tasgi-0.1.0a1/tests/test_http2.py +393 -0
  45. tasgi-0.1.0a1/tests/test_openapi.py +299 -0
  46. tasgi-0.1.0a1/tests/test_request_response.py +130 -0
  47. tasgi-0.1.0a1/tests/test_router.py +268 -0
  48. tasgi-0.1.0a1/tests/test_streaming.py +57 -0
  49. tasgi-0.1.0a1/tests/test_thread_runtime.py +292 -0
  50. tasgi-0.1.0a1/tests/test_websocket.py +172 -0
tasgi-0.1.0a1/LICENSE ADDED
@@ -0,0 +1,183 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form, made
34
+ available under the License, as indicated by a copyright notice that is included
35
+ in or attached to the work (an example is provided in the Appendix below).
36
+
37
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
38
+ is based on (or derived from) the Work and for which the editorial revisions,
39
+ annotations, elaborations, or other modifications represent, as a whole, an
40
+ original work of authorship. For the purposes of this License, Derivative Works
41
+ shall not include works that remain separable from, or merely link (or bind by
42
+ name) to the interfaces of, the Work and Derivative Works thereof.
43
+
44
+ "Contribution" shall mean any work of authorship, including the original version
45
+ of the Work and any modifications or additions to that Work or Derivative Works
46
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
47
+ by the copyright owner or by an individual or Legal Entity authorized to submit
48
+ on behalf of the copyright owner. For the purposes of this definition,
49
+ "submitted" means any form of electronic, verbal, or written communication sent
50
+ to the Licensor or its representatives, including but not limited to
51
+ communication on electronic mailing lists, source code control systems, and
52
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
53
+ the purpose of discussing and improving the Work, but excluding communication
54
+ that is conspicuously marked or otherwise designated in writing by the copyright
55
+ owner as "Not a Contribution."
56
+
57
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58
+ of whom a Contribution has been received by Licensor and subsequently
59
+ incorporated within the Work.
60
+
61
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
62
+ License, each Contributor hereby grants to You a perpetual, worldwide,
63
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
64
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
65
+ sublicense, and distribute the Work and such Derivative Works in Source or
66
+ Object form.
67
+
68
+ 3. Grant of Patent License. Subject to the terms and conditions of this License,
69
+ each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
70
+ no-charge, royalty-free, irrevocable (except as stated in this section) patent
71
+ license to make, have made, use, offer to sell, sell, import, and otherwise
72
+ transfer the Work, where such license applies only to those patent claims
73
+ licensable by such Contributor that are necessarily infringed by their
74
+ Contribution(s) alone or by combination of their Contribution(s) with the Work
75
+ to which such Contribution(s) was submitted. If You institute patent litigation
76
+ against any entity (including a cross-claim or counterclaim in a lawsuit)
77
+ alleging that the Work or a Contribution incorporated within the Work
78
+ constitutes direct or contributory patent infringement, then any patent licenses
79
+ granted to You under this License for that Work shall terminate as of the date
80
+ such litigation is filed.
81
+
82
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
83
+ Derivative Works thereof in any medium, with or without modifications, and in
84
+ Source or Object form, provided that You meet the following conditions:
85
+
86
+ (a) You must give any other recipients of the Work or Derivative Works a copy of
87
+ this License; and
88
+
89
+ (b) You must cause any modified files to carry prominent notices stating that You
90
+ changed the files; and
91
+
92
+ (c) You must retain, in the Source form of any Derivative Works that You
93
+ distribute, all copyright, patent, trademark, and attribution notices from the
94
+ Source form of the Work, excluding those notices that do not pertain to any part
95
+ of the Derivative Works; and
96
+
97
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
98
+ any Derivative Works that You distribute must include a readable copy of the
99
+ attribution notices contained within such NOTICE file, excluding those notices
100
+ that do not pertain to any part of the Derivative Works, in at least one of the
101
+ following places: within a NOTICE text file distributed as part of the
102
+ Derivative Works; within the Source form or documentation, if provided along
103
+ with the Derivative Works; or, within a display generated by the Derivative
104
+ Works, if and wherever such third-party notices normally appear. The contents of
105
+ the NOTICE file are for informational purposes only and do not modify the
106
+ License. You may add Your own attribution notices within Derivative Works that
107
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
108
+ provided that such additional attribution notices cannot be construed as
109
+ modifying the License.
110
+
111
+ You may add Your own copyright statement to Your modifications and may provide
112
+ additional or different license terms and conditions for use, reproduction, or
113
+ distribution of Your modifications, or for any such Derivative Works as a whole,
114
+ provided Your use, reproduction, and distribution of the Work otherwise complies
115
+ with the conditions stated in this License.
116
+
117
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
118
+ Contribution intentionally submitted for inclusion in the Work by You to the
119
+ Licensor shall be under the terms and conditions of this License, without any
120
+ additional terms or conditions. Notwithstanding the above, nothing herein shall
121
+ supersede or modify the terms of any separate license agreement you may have
122
+ executed with Licensor regarding such Contributions.
123
+
124
+ 6. Trademarks. This License does not grant permission to use the trade names,
125
+ trademarks, service marks, or product names of the Licensor, except as required
126
+ for reasonable and customary use in describing the origin of the Work and
127
+ reproducing the content of the NOTICE file.
128
+
129
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
130
+ writing, Licensor provides the Work (and each Contributor provides its
131
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
132
+ KIND, either express or implied, including, without limitation, any warranties
133
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
134
+ PARTICULAR PURPOSE. You are solely responsible for determining the
135
+ appropriateness of using or redistributing the Work and assume any risks
136
+ associated with Your exercise of permissions under this License.
137
+
138
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
139
+ tort (including negligence), contract, or otherwise, unless required by
140
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
141
+ writing, shall any Contributor be liable to You for damages, including any
142
+ direct, indirect, special, incidental, or consequential damages of any character
143
+ arising as a result of this License or out of the use or inability to use the
144
+ Work (including but not limited to damages for loss of goodwill, work stoppage,
145
+ computer failure or malfunction, or any and all other commercial damages or
146
+ losses), even if such Contributor has been advised of the possibility of such
147
+ damages.
148
+
149
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
150
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
151
+ acceptance of support, warranty, indemnity, or other liability obligations
152
+ and/or rights consistent with this License. However, in accepting such
153
+ obligations, You may act only on Your own behalf and on Your sole responsibility,
154
+ not on behalf of any other Contributor, and only if You agree to indemnify,
155
+ defend, and hold each Contributor harmless for any liability incurred by, or
156
+ claims asserted against, such Contributor by reason of your accepting any such
157
+ warranty or additional liability.
158
+
159
+ END OF TERMS AND CONDITIONS
160
+
161
+ APPENDIX: How to apply the Apache License to your work.
162
+
163
+ To apply the Apache License to your work, attach the following boilerplate
164
+ notice, with the fields enclosed by brackets "[]" replaced with your own
165
+ identifying information. (Don't include the brackets!) The text should be
166
+ enclosed in the appropriate comment syntax for the file format. We also
167
+ recommend that a file or class name and description of purpose be included on
168
+ the same "printed page" as the copyright notice for easier identification
169
+ within third-party archives.
170
+
171
+ Copyright [yyyy] [name of copyright owner]
172
+
173
+ Licensed under the Apache License, Version 2.0 (the "License");
174
+ you may not use this file except in compliance with the License.
175
+ You may obtain a copy of the License at
176
+
177
+ http://www.apache.org/licenses/LICENSE-2.0
178
+
179
+ Unless required by applicable law or agreed to in writing, software
180
+ distributed under the License is distributed on an "AS IS" BASIS,
181
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
182
+ See the License for the specific language governing permissions and
183
+ limitations under the License.
tasgi-0.1.0a1/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ tasgi
2
+ Copyright 2026 Vachagan
3
+
4
+ This product includes software developed by Vachagan.
tasgi-0.1.0a1/PKG-INFO ADDED
@@ -0,0 +1,506 @@
1
+ Metadata-Version: 2.4
2
+ Name: tasgi
3
+ Version: 0.1.0a1
4
+ Summary: Experimental thread-aware ASGI framework and runtime prototype.
5
+ Author: Vachagan
6
+ License: Apache License
7
+ Version 2.0, January 2004
8
+ http://www.apache.org/licenses/
9
+
10
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
+
12
+ 1. Definitions.
13
+
14
+ "License" shall mean the terms and conditions for use, reproduction, and
15
+ distribution as defined by Sections 1 through 9 of this document.
16
+
17
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
18
+ owner that is granting the License.
19
+
20
+ "Legal Entity" shall mean the union of the acting entity and all other entities
21
+ that control, are controlled by, or are under common control with that entity.
22
+ For the purposes of this definition, "control" means (i) the power, direct or
23
+ indirect, to cause the direction or management of such entity, whether by
24
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
25
+ outstanding shares, or (iii) beneficial ownership of such entity.
26
+
27
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
28
+ permissions granted by this License.
29
+
30
+ "Source" form shall mean the preferred form for making modifications, including
31
+ but not limited to software source code, documentation source, and configuration
32
+ files.
33
+
34
+ "Object" form shall mean any form resulting from mechanical transformation or
35
+ translation of a Source form, including but not limited to compiled object code,
36
+ generated documentation, and conversions to other media types.
37
+
38
+ "Work" shall mean the work of authorship, whether in Source or Object form, made
39
+ available under the License, as indicated by a copyright notice that is included
40
+ in or attached to the work (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
43
+ is based on (or derived from) the Work and for which the editorial revisions,
44
+ annotations, elaborations, or other modifications represent, as a whole, an
45
+ original work of authorship. For the purposes of this License, Derivative Works
46
+ shall not include works that remain separable from, or merely link (or bind by
47
+ name) to the interfaces of, the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including the original version
50
+ of the Work and any modifications or additions to that Work or Derivative Works
51
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
52
+ by the copyright owner or by an individual or Legal Entity authorized to submit
53
+ on behalf of the copyright owner. For the purposes of this definition,
54
+ "submitted" means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems, and
57
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
58
+ the purpose of discussing and improving the Work, but excluding communication
59
+ that is conspicuously marked or otherwise designated in writing by the copyright
60
+ owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
63
+ of whom a Contribution has been received by Licensor and subsequently
64
+ incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
67
+ License, each Contributor hereby grants to You a perpetual, worldwide,
68
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
69
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
70
+ sublicense, and distribute the Work and such Derivative Works in Source or
71
+ Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of this License,
74
+ each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
75
+ no-charge, royalty-free, irrevocable (except as stated in this section) patent
76
+ license to make, have made, use, offer to sell, sell, import, and otherwise
77
+ transfer the Work, where such license applies only to those patent claims
78
+ licensable by such Contributor that are necessarily infringed by their
79
+ Contribution(s) alone or by combination of their Contribution(s) with the Work
80
+ to which such Contribution(s) was submitted. If You institute patent litigation
81
+ against any entity (including a cross-claim or counterclaim in a lawsuit)
82
+ alleging that the Work or a Contribution incorporated within the Work
83
+ constitutes direct or contributory patent infringement, then any patent licenses
84
+ granted to You under this License for that Work shall terminate as of the date
85
+ such litigation is filed.
86
+
87
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
88
+ Derivative Works thereof in any medium, with or without modifications, and in
89
+ Source or Object form, provided that You meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative Works a copy of
92
+ this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices stating that You
95
+ changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works that You
98
+ distribute, all copyright, patent, trademark, and attribution notices from the
99
+ Source form of the Work, excluding those notices that do not pertain to any part
100
+ of the Derivative Works; and
101
+
102
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
103
+ any Derivative Works that You distribute must include a readable copy of the
104
+ attribution notices contained within such NOTICE file, excluding those notices
105
+ that do not pertain to any part of the Derivative Works, in at least one of the
106
+ following places: within a NOTICE text file distributed as part of the
107
+ Derivative Works; within the Source form or documentation, if provided along
108
+ with the Derivative Works; or, within a display generated by the Derivative
109
+ Works, if and wherever such third-party notices normally appear. The contents of
110
+ the NOTICE file are for informational purposes only and do not modify the
111
+ License. You may add Your own attribution notices within Derivative Works that
112
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
113
+ provided that such additional attribution notices cannot be construed as
114
+ modifying the License.
115
+
116
+ You may add Your own copyright statement to Your modifications and may provide
117
+ additional or different license terms and conditions for use, reproduction, or
118
+ distribution of Your modifications, or for any such Derivative Works as a whole,
119
+ provided Your use, reproduction, and distribution of the Work otherwise complies
120
+ with the conditions stated in this License.
121
+
122
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
123
+ Contribution intentionally submitted for inclusion in the Work by You to the
124
+ Licensor shall be under the terms and conditions of this License, without any
125
+ additional terms or conditions. Notwithstanding the above, nothing herein shall
126
+ supersede or modify the terms of any separate license agreement you may have
127
+ executed with Licensor regarding such Contributions.
128
+
129
+ 6. Trademarks. This License does not grant permission to use the trade names,
130
+ trademarks, service marks, or product names of the Licensor, except as required
131
+ for reasonable and customary use in describing the origin of the Work and
132
+ reproducing the content of the NOTICE file.
133
+
134
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
135
+ writing, Licensor provides the Work (and each Contributor provides its
136
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
137
+ KIND, either express or implied, including, without limitation, any warranties
138
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
139
+ PARTICULAR PURPOSE. You are solely responsible for determining the
140
+ appropriateness of using or redistributing the Work and assume any risks
141
+ associated with Your exercise of permissions under this License.
142
+
143
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
144
+ tort (including negligence), contract, or otherwise, unless required by
145
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
146
+ writing, shall any Contributor be liable to You for damages, including any
147
+ direct, indirect, special, incidental, or consequential damages of any character
148
+ arising as a result of this License or out of the use or inability to use the
149
+ Work (including but not limited to damages for loss of goodwill, work stoppage,
150
+ computer failure or malfunction, or any and all other commercial damages or
151
+ losses), even if such Contributor has been advised of the possibility of such
152
+ damages.
153
+
154
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
155
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
156
+ acceptance of support, warranty, indemnity, or other liability obligations
157
+ and/or rights consistent with this License. However, in accepting such
158
+ obligations, You may act only on Your own behalf and on Your sole responsibility,
159
+ not on behalf of any other Contributor, and only if You agree to indemnify,
160
+ defend, and hold each Contributor harmless for any liability incurred by, or
161
+ claims asserted against, such Contributor by reason of your accepting any such
162
+ warranty or additional liability.
163
+
164
+ END OF TERMS AND CONDITIONS
165
+
166
+ APPENDIX: How to apply the Apache License to your work.
167
+
168
+ To apply the Apache License to your work, attach the following boilerplate
169
+ notice, with the fields enclosed by brackets "[]" replaced with your own
170
+ identifying information. (Don't include the brackets!) The text should be
171
+ enclosed in the appropriate comment syntax for the file format. We also
172
+ recommend that a file or class name and description of purpose be included on
173
+ the same "printed page" as the copyright notice for easier identification
174
+ within third-party archives.
175
+
176
+ Copyright [yyyy] [name of copyright owner]
177
+
178
+ Licensed under the Apache License, Version 2.0 (the "License");
179
+ you may not use this file except in compliance with the License.
180
+ You may obtain a copy of the License at
181
+
182
+ http://www.apache.org/licenses/LICENSE-2.0
183
+
184
+ Unless required by applicable law or agreed to in writing, software
185
+ distributed under the License is distributed on an "AS IS" BASIS,
186
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
187
+ See the License for the specific language governing permissions and
188
+ limitations under the License.
189
+
190
+ Keywords: asgi,asyncio,threads,http,websocket,openapi
191
+ Classifier: Development Status :: 3 - Alpha
192
+ Classifier: Intended Audience :: Developers
193
+ Classifier: License :: OSI Approved :: Apache Software License
194
+ Classifier: Operating System :: OS Independent
195
+ Classifier: Programming Language :: Python :: 3
196
+ Classifier: Programming Language :: Python :: 3.9
197
+ Classifier: Programming Language :: Python :: 3.10
198
+ Classifier: Programming Language :: Python :: 3.11
199
+ Classifier: Programming Language :: Python :: 3.12
200
+ Classifier: Programming Language :: Python :: 3.13
201
+ Classifier: Programming Language :: Python :: 3.14
202
+ Classifier: Framework :: AsyncIO
203
+ Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
204
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
205
+ Requires-Python: >=3.9
206
+ Description-Content-Type: text/markdown
207
+ License-File: LICENSE
208
+ License-File: NOTICE
209
+ Dynamic: license-file
210
+
211
+ # tasgi
212
+
213
+ `tasgi` means Thread ASGI. It is an experimental ASGI-compatible framework/runtime that keeps transport and protocol handling on the event loop while allowing handler execution on either the asyncio loop or a thread runtime.
214
+
215
+ Runtime design goal:
216
+
217
+ - the `tasgi` package itself depends only on the Python standard library
218
+ - external tools like `coverage`, `build`, and `twine` are used only for CI, testing, and packaging
219
+
220
+ ## Status
221
+
222
+ `tasgi` is currently an alpha-stage project.
223
+
224
+ - public APIs are still settling
225
+ - auth APIs are still evolving
226
+ - router/module composition is still evolving
227
+ - native HTTP/2 support is still a prototype subset
228
+
229
+ Treat the current release line as experimental, not stable.
230
+
231
+ ## Install
232
+
233
+ From source:
234
+
235
+ ```bash
236
+ pip install -e .
237
+ ```
238
+
239
+ `tasgi` does not require Poetry at runtime. The project is packaged from `pyproject.toml`
240
+ using the standard PEP 517 build flow, so CI and publishing use `pip`, `build`, and `twine`
241
+ directly instead of a Poetry-specific workflow.
242
+
243
+ After packaging to TestPyPI, the intended trial install flow is:
244
+
245
+ ```bash
246
+ pip install --index-url https://test.pypi.org/simple/ tasgi
247
+ ```
248
+
249
+ ## Hello World
250
+
251
+ ```python
252
+ from tasgi import TasgiApp, TextResponse
253
+
254
+ app = TasgiApp(docs=True, debug=True)
255
+
256
+ @app.route.get("/")
257
+ async def home(request):
258
+ return TextResponse("hello from tasgi")
259
+ ```
260
+
261
+ Run it:
262
+
263
+ ```bash
264
+ tasgi
265
+ ```
266
+
267
+ Or run the bundled demo app:
268
+
269
+ ```bash
270
+ python3 examples/service_api/main.py
271
+ ```
272
+
273
+ ## Router Usage
274
+
275
+ `tasgi` now treats `app.route` as the main HTTP registration surface.
276
+
277
+ ```python
278
+ from tasgi import JsonResponse, Router, TasgiApp
279
+
280
+ users = Router(tags=["users"])
281
+
282
+ @users.get("/users")
283
+ def list_users(request):
284
+ return ["alice", "bob"]
285
+
286
+ app = TasgiApp()
287
+ app.include_router(users, prefix="/api")
288
+
289
+ @app.route.get("/status")
290
+ async def status(request):
291
+ return JsonResponse({"ok": True})
292
+ ```
293
+
294
+ ## Core Model
295
+
296
+ `tasgi` is layered like this:
297
+
298
+ ```text
299
+ socket/transport
300
+ -> ASGI boundary
301
+ -> tasgi runtime
302
+ -> tasgi framework
303
+ -> user handlers
304
+ ```
305
+
306
+ Rules:
307
+
308
+ - network I/O stays on the event loop
309
+ - HTTP protocol handling stays on the event loop
310
+ - async handlers run on the asyncio loop
311
+ - sync handlers run in the tasgi thread runtime
312
+ - worker threads never write directly to sockets
313
+
314
+ ## Dual Execution Model
315
+
316
+ App-level execution policy is explicit:
317
+
318
+ ```python
319
+ from tasgi import ASYNC_EXECUTION, THREAD_EXECUTION, TasgiApp
320
+
321
+ app = TasgiApp(default_execution=THREAD_EXECUTION)
322
+
323
+ @app.route.get("/cpu")
324
+ def cpu(request):
325
+ ...
326
+
327
+ @app.route.get("/status", execution=ASYNC_EXECUTION)
328
+ async def status(request):
329
+ ...
330
+ ```
331
+
332
+ ## Request And Response Types
333
+
334
+ Main public HTTP types:
335
+
336
+ - `TasgiApp`
337
+ - `Router`
338
+ - `Request`
339
+ - `Response`
340
+ - `TextResponse`
341
+ - `JsonResponse`
342
+ - `StreamingResponse`
343
+
344
+ Handlers may return `Response` objects directly, or return typed values when a response model is declared.
345
+
346
+ ## OpenAPI And Docs
347
+
348
+ Built-in docs can be enabled from app config:
349
+
350
+ ```python
351
+ from dataclasses import dataclass
352
+ from tasgi import TasgiApp
353
+
354
+ @dataclass
355
+ class EchoIn:
356
+ message: str
357
+
358
+ @dataclass
359
+ class EchoOut:
360
+ echoed: str
361
+
362
+ app = TasgiApp(
363
+ docs=True,
364
+ title="tasgi demo",
365
+ version="0.1.0a1",
366
+ )
367
+
368
+ @app.route.post("/echo", request_model=EchoIn, response_model=EchoOut)
369
+ def echo(request, body: EchoIn) -> EchoOut:
370
+ return EchoOut(echoed=body.message)
371
+ ```
372
+
373
+ Default docs endpoints:
374
+
375
+ - `/openapi.json`
376
+ - `/docs`
377
+
378
+ ## Auth
379
+
380
+ `tasgi` includes an experimental pluggable auth layer.
381
+
382
+ Built-in starters:
383
+
384
+ - `BearerTokenBackend`
385
+ - `APIKeyBackend`
386
+ - `BasicAuthBackend`
387
+ - `RequireAuthenticated`
388
+ - `RequireScope`
389
+ - `RequireRole`
390
+
391
+ Example:
392
+
393
+ ```python
394
+ from tasgi import BearerTokenBackend, Identity, RequireScope, TasgiApp
395
+
396
+ def validate_token(token: str):
397
+ if token == "demo-token":
398
+ return Identity(subject="alice", scopes=frozenset({"profile"}))
399
+ if token == "admin-token":
400
+ return Identity(subject="admin", scopes=frozenset({"admin"}))
401
+ return None
402
+
403
+ app = TasgiApp(auth_backend=BearerTokenBackend(validate_token), docs=True)
404
+
405
+ @app.route.get("/public", auth=False)
406
+ async def public_route(request):
407
+ return {"public": True}
408
+
409
+ @app.route.get("/me", auth=True)
410
+ async def me(request):
411
+ return {"subject": request.identity.subject}
412
+
413
+ @app.route.get("/admin", auth=RequireScope("admin"))
414
+ async def admin(request):
415
+ return {"subject": request.identity.subject}
416
+ ```
417
+
418
+ Auth metadata is also reflected automatically in OpenAPI for built-in auth backends.
419
+
420
+ ## Demo App
421
+
422
+ The bundled service example includes:
423
+
424
+ - HTTP routes
425
+ - router/module composition
426
+ - OpenAPI + Swagger UI
427
+ - auth examples
428
+ - streaming responses
429
+ - WebSocket echo
430
+ - thread-executed sync handlers
431
+
432
+ Run:
433
+
434
+ ```bash
435
+ python3 examples/service_api/main.py
436
+ ```
437
+
438
+ There is also a cleaner modular composition example:
439
+
440
+ ```bash
441
+ python3 examples/modular_api/main.py
442
+ ```
443
+
444
+ ## Benchmarks
445
+
446
+ The benchmark suite exercises loopback TCP requests against a dedicated benchmark app.
447
+
448
+ Run:
449
+
450
+ ```bash
451
+ python3 benchmarks/run_benchmarks.py
452
+ ```
453
+
454
+ ## CI And Publishing
455
+
456
+ GitHub Actions workflows are set up for both validation and releases:
457
+
458
+ - `CI` runs on every push and pull request
459
+ - the primary CI target is free-threaded CPython `3.14t`
460
+ - standard compatibility tests also run on Python 3.14, 3.13, 3.12, and 3.11
461
+ - coverage is reported in CI using `coverage run -m unittest discover -s tests`
462
+ - package builds are verified in CI with `python -m build` and `python -m twine check --strict dist/*`
463
+
464
+ Publishing is separated from CI:
465
+
466
+ - `Publish` runs only on version tags like `v0.1.0a1` or on published GitHub Releases
467
+ - release builds run on CPython `3.14t`
468
+ - PyPI upload is configured for Trusted Publishing via GitHub Actions
469
+ - before enabling real PyPI releases, do one TestPyPI dry run and confirm a clean install path
470
+
471
+ Local commands:
472
+
473
+ ```bash
474
+ python3 -m unittest discover -s tests -v
475
+ python3 -m pip install coverage build twine
476
+ coverage run -m unittest discover -s tests
477
+ coverage report -m
478
+ python3 -m build
479
+ python3 -m twine check --strict dist/*
480
+ ```
481
+
482
+ ## Current Limits
483
+
484
+ - HTTP/2 support is prototype-grade, not production-complete
485
+ - auth API is still settling
486
+ - route registration APIs changed recently and may still evolve
487
+ - no middleware ecosystem yet
488
+ - no dependency injection container beyond explicit lightweight helpers
489
+ - no production-hardening claims
490
+
491
+ ## License
492
+
493
+ `tasgi` is licensed under Apache-2.0. See `LICENSE` and `NOTICE`.
494
+
495
+ That keeps the project free to use, including in companies, while preserving
496
+ the attribution notices when the software is redistributed.
497
+
498
+ ## Release Notes
499
+
500
+ This repository is currently prepared for an alpha-style release, not a stable release.
501
+
502
+ Before a public non-alpha release, the project still needs:
503
+
504
+ - final public API freeze
505
+ - repository/homepage URLs in package metadata
506
+ - a TestPyPI install-and-verify pass