Skip to content

Instantly share code, notes, and snippets.

@lixit
Last active December 10, 2019 07:00
Show Gist options
  • Save lixit/f9023457e410a6db1593ff611165943c to your computer and use it in GitHub Desktop.
Save lixit/f9023457e410a6db1593ff611165943c to your computer and use it in GitHub Desktop.

ASGI (Asynchronous Server Gateway Interface) Specification

ASGI consists of two different components:

  1. A protocol server, which terminates sockets and translates them into connections and per-connection event messages.
  2. An application, which lives inside a protocol server, is instantiated once per connection, and handles event messages as they happen.
socket  ---> protocol server  ------->  application
                                event  
                                connection scope

ASGI connection:

  1. A connection scope, which represents a protocol connection to a user and survives until the connection closes.
  2. Events, which are sent to the application as things happen on the connection.
                              interface                         
  network protocol servers  <-------------> Python applications
(particularly web servers)
  1. Implementations
    1. Servers Uvicorn:
      A fast ASGI server based on uvloop and httptools. Supports HTTP/1 and WebSockets.
    2. Application Frameworks Starlette:
      Starlette is a minimalist ASGI library for writing against basic but powerful Request and Response classes. Supports HTTP.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment