The web isn’t a pure request/response web anymore. There’s real-time web now. There are lots of tools (yeah!), but you also get lots of complexity (booo!).
Django channels is a framework to use django in the non-http world. Websockets, but not only those. Channels (version 1) is out now for three years, version 2 came out a few months ago. The talk assumes version 2.
Asynchronous. For us, this means event-driven. A problem is that asynchronous code is normally harder to understand because of its non-linear nature.
But… channels hides most of the complexity for you.
ASGI. A protocol spec (like WSGI), independent of channels.
It is ASGI all the way down. You can nest them.
Protocol server. This implements the ASGI spec for a specific protocol. It interacts with the connection. It bridges the network and the application.
For channels, this often is ‘daphne’.
Routing. Maps incoming messages to consumers. It is nestable and composable.
Scope. A “scope” is created for every connection. It holds the data of the connection.
Channel. IPC mechanism (“Inter Process Communication”). FIFO “at-most-once” queue.
Consumers. The core abstraction to build an ASGI app. It handles events on a connection. It is stateful: every individual connection is connected to an individual consumer.
Note on stateful: everything runs in a single process.
Events. Triggered during a “scope”. In the end, consumers consume events.
He showed a demo and then some code. (I couldn’t type over the example code, of course :-) ).
receive(... event ...).
Summary of channels:
Photo explanation: interiors means something like this. The office of the manager.
My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.
Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):