What is aioscgi?
aioscgi is a container implementing the Asynchronous Server Gateway Interface
ASGI to serve up asynchronous Web applications
via the Simple Common Gateway Interface protocol. aioscgi supports listening on
TCP or UNIX-domain sockets, as well as using sockets passed in via the systemd
socket-passing protocol. In a systemd environment, when running as a service,
it supports Type=notify.
What is SCGI?
SCGI is a protocol used for communication between HTTP servers and Web applications. Compared to CGI, SCGI is more efficient because it does not fork and execute a separate instance of the application for every request; instead, the application is launched ahead of time and receives multiple requests (either sequentially or concurrently) via socket connections. Compared to FastCGI, SCGI is a much simpler protocol as it uses a separate socket connection for each request, rather than including framing within a single connection to multiplex requests (a feature which is rarely used in FastCGI anyway due to the lack of per-request flow control).
See the Wikipedia and Python SCGI pages for more information.
How do I install it?
aioscgi’s releases are published on PyPI for installation through pip. You can
run pip install aioscgi.
For development, the source is available at GitLab and GitHub.
How do I use it?
aioscgi installs an aioscgi executable. If your ASGI application callable is
named myapp and is in a file called mypackage/mymodule.py, you might run
aioscgi --unix-socket /path/to/socket mypackage.mymodule:myapp. For full
details on available options, run aioscgi --help.
What ASGI protocols does it implement?
aioscgi implements the http and lifespan protocols.
What ASGI extensions does it implement?
environ
aioscgi implements a non-standard extension in the http scope named
environ. scope["extensions"]["environ"] is a dictionary with str keys and
bytes values containing the entire CGI environment, exactly as sent by the
SCGI client. This can be used to extract values that the ASGI specification
does not provide a home for.
http.response.pathsend
aioscgi implements the HTTP Path Send
extension
using the X-Sendfile header. Because it is not possible to automatically
detect whether a given HTTP server understands that header or not, support is
disabled by default and must be enabled with a command-line option.
How does it connect to the rest of my system?
Listening
aioscgi can listen on one or more TCP or UNIX-domain sockets. It can also use listening TCP or UNIX-domain sockets given to it via systemd socket passing. It can listen on multiple sockets, including sockets of different domains and/or a mixture of created sockets and passed sockets, at the same time.
Startup notification
aioscgi supports the systemd service status notification protocol and therefore can be
invoked as a service with Type=notify. It reports startup complete (READY=1) after
the application’s lifespan protocol startup process (if any) is complete and any
listening sockets created by aioscgi itself have been created. It reports shutdown in
progress (STOPPING=1) as soon as it is instructed to begin shutting down.
Control
On a UNIX system, aioscgi handles three signals:
- When aioscgi receives
SIGINT, it immediately stops accepting new connections on any listening socket. It then waits for all existing tasks that were spawned to handle client connections to end naturally before performing lifespan protocol shutdown and terminating. FurtherSIGINTs after the first are ignored. - When aioscgi receives
SIGTERM, it behaves exactly the same asSIGINT. - When aioscgi receives
SIGQUIT, it does everything described forSIGINT, except that it also raises a cancellation exception in every task that was spawned to handle a client connection with the intention of making them stop faster.SIGQUITcan also be sent afterSIGINTorSIGTERM, in which case the cancellation exception is raised in any still-running client-connection-handling tasks. FurtherSIGQUITs after the first are ignored. Even thoughSIGQUITcancels client-connection-handling tasks, the application’s lifespan protocol task (if any) is not cancelled and the normal lifespan shutdown process still occurs.
Metadata
Release files for aioscgi 2.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aioscgi-2.4.0.tar.gz | 26.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aioscgi-2.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 49.9 kB
Release files / aioscgi-2.4.0.tar.gz
| Download URL | aioscgi-2.4.0.tar.gz |
|---|---|
| Size | 26.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d41eafe93362c7005113144e039d2f95910174148d095af1f56059c6e3a609b
|
|
BLAKE2b-256 checksum How to use checksums |
5956d69ec4cf4f8133fc51a921f8aec05fe133197084cca6c55aacffc9a06726
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / aioscgi-2.4.0-py3-none-any.whl
| Download URL | aioscgi-2.4.0-py3-none-any.whl |
|---|---|
| Size | 23.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf334584ef022df5951634dde9a48d8ed1e5c83f31f23753226b34eeb17d377f
|
|
BLAKE2b-256 checksum How to use checksums |
54ccdf2b9143149eec439ec7bac196de1907adb8477dda480e820822533bbed7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|