Skip to content

Commit 7e7b71a

Browse files
authored
Updates docs example to conform ASGI 3 specs (#1624)
1 parent adf5839 commit 7e7b71a

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

docs/asgi.rst

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@ The full ASGI spec can be found at http://asgi.readthedocs.io
1616
Summary
1717
-------
1818

19-
An ASGI application is a callable that takes a scope and returns a coroutine
20-
callable, that takes receive and send methods. It's usually written as a class:
19+
ASGI is structured as a single asynchronous callable, which takes a dict ``scope``
20+
and two callables ``receive`` and ``send``:
2121

2222
.. code-block:: python
2323
24-
class Application:
25-
26-
def __init__(self, scope):
27-
...
28-
29-
async def __call__(self, receive, send):
30-
...
24+
async def application(scope, receive, send):
25+
event = await receive()
26+
...
27+
await send({"type": "websocket.send", ...})
3128
3229
The ``scope`` dict defines the properties of a connection, like its remote IP (for
3330
HTTP) or username (for a chat protocol), and the lifetime of a connection.

0 commit comments

Comments
 (0)