←back to thread

Happy 20th Birthday, Django

(www.djangoproject.com)
578 points davepeck | 4 comments | | HN request time: 1.079s | source
1. zenkey ◴[] No.44559849[source]
Love Django + Django-ninja but the clunky and incomplete async support is painful.
replies(1): >>44560769 #
2. calpaterson ◴[] No.44560769[source]
What is missing? The ORM works with asyncio, you can have async views, you can have long running connection-oriented async stuff for websockets etc (via django channels). Maybe there is something important that I'm missing but that seems more complete than most async-only frameworks.
replies(1): >>44570078 #
3. sebra ◴[] No.44570078[source]
There are numerous things still missing in terms of async support. Most notably for me is DB transaction support which leads to most non-safe endpoints running on the shared sync_to_async thread and me having to separate my code into one async function calling another sync function wrapped in sync_to_async.

In fact if you look at the source there is a lot of async methods in the framework itself which just straight up calls sync_to_async e.g. caching. This doesn't matter as much as hopefully it will get added proper async eventually. But I think believing your requests wont block just because you're using async is a bit naive at this point in Django and the async implementation has been going for years.

Not to mention that the majority of third party libraries lack support for async so you'll probably have to write your own wrappers for e.g. middleware.

replies(1): >>44585012 #
4. calpaterson ◴[] No.44585012{3}[source]
> But I think believing your requests wont block just because you're using async is a bit naive at this point in Django

TBH personally I have yet to work on any professional async Python project (Django based or not) which did not have event loop pauses due to accidental blocking IO or CPU exhaustion.

I take your point fully though that a lot of Django's "async" methods are really using a thread pool. (True for much closed source async code as well!)