Asynchronous Server Gateway Interface (ASGI)

From GM-RKB
Jump to navigation Jump to search

A Asynchronous Server Gateway Interface (ASGI) is a Python specification for asynchronous web servers and asynchronous applications.

  • Context:
    • It can provide a standard interface between async-capable Python web servers, frameworks, and applications.
    • It can allow the handling of multiple, asynchronous events per application.
    • It can support both synchronous and asynchronous applications, offering backward compatibility with WSGI.
    • It can use a single asynchronous callable, which takes a `dict` `scope` and two callables `receive` and `send`.
    • It can define the properties of a connection and the lifetime of a connection through the `scope` dict.
    • It can provide events as dicts through the `receive` awaitable and sends events back to the client through the `send` awaitable in a similar dict format.
    • It can have middleware that plays the role of both server and application, taking in a `scope` and the `send`/`receive` awaitables, potentially modifying them, and then calling an inner application.
    • It can include protocol specifications that describe the standardized scope and message formats for various protocols, such as HTTP and WebSocket.
    • ...
  • Example(s):
  • Counter-Example(s):
  • See: asyncio, aiohttp, Public Domain, GitHub, Web Server, Asynchronous Method Invocation, Python (Programming Language).


References

2024