|
|
|
|
|
by 904baf11
2384 days ago
|
|
> ASGI support > Django 3.0 begins our journey to making Django fully async-capable by providing support for running as an ASGI application. Bleh. ASGI is probably the worst implementation I can think of for a common async interface. Stringly-typed callbacks? async generators exist for a good reason. It's also very asyncio-centric, and asyncio is Not Good. |
|
Having worked and developed with it extensively for over a year now, ASGI is one of the most elegant and well-designed interfaces I've seen.
Just wanted to address this:
> async generators exist for a good reason.
While the idea of using async generators might sound attractive at first, there's so much more to ASGI than exchanging messages in both directions.
Even on that aspect, I'd be interested in knowing how you'd achieve bidirectional communication async generators. How would the ASGI server call into the application and handle messages coming both ways? Surely, it can't just `async for message in agen: ...`, as that would only replicate the `send()` ASGI callback — what about `receive()`?
Besides, how would middleware look? Would it be as simple as wrapping `receive()` and `send()` into whichever other callable adds the functionality your middleware needs?
And you probably wouldn't be able to support all the possible syntactical implementations allowed by the notion of a Python callable: functions, classes, callable class instances.
So, yeah, I think ASGI is a beast.
Also, I wholeheartedly congratulate the Django team for pushing the standard out there and driving the Python async web ecosystem forward. You rock!