by j4mie on 8/3/22, 9:13 AM with 125 comments
by zzzeek on 8/3/22, 2:46 PM
we at SQLAlchemy came up with a way to interface asyncio frontend and backend (like asyncpg for the driver) while maintaining all the "in the middle" code as synchronous style. the dark secret is that for this approach you have to use greenlet to propagate the "await" operations. It's been in our release for 18 months now with 1M downloads a day and there have been no problems reported with it, so i continue to wonder why nobody else seems to want to look at this approach. one downside which nobody has complained about yet is that it makes profiling tools like cProfile harder to use, but seems not to have come up yet.
there's also another approach, which is that you rewrite all your "in the middle" code as pure asyncio, then create a dummy task to implement your synchronous API. dark secret for that one is you had to rewrite everything and I'm not sure if there's other performance implications for having awaits all throughout code that's running only one task per thread.
by nickjj on 8/3/22, 11:10 AM
It includes running Django, Celery, gunicorn, Postgres, Redis, esbuild and Tailwind through Docker and Docker Compose. It's set up for development and production.
by hansonkd13 on 8/3/22, 2:55 PM
In order for async to be popular it needs to be the default way of writing python. Right now its an after thought for writing “high performance” python. For example asyncio version of redis got 72,114 downloads this month. The sync version got 26,825,663. Thats not even in the same universe.
Historically, using something like gevent is a more drop-in solution for python if you want lightweight threads, but it comes with its own problems. Gevent gives python what Zig has that automatically turns all sync IO calls to async and your app is now magically using greenthreads.
However I think gevent in the past was the crutch that prevented a lot of lib authors from writing async libs.
by WhatsName on 8/3/22, 10:48 AM
Sure most CRUD applications work perfectly fine using WSGI, but for anyone using other protocols like WS or MQTT in their app this is kind of a big deal.
by BiteCode_dev on 8/3/22, 2:28 PM
And if you like django and never tried django ninja, it's like DRF and FastAPI had a baby: https://django-ninja.rest-framework.com/. You define your endpoints using pydantic type hints, and it generates the API, validators and docs all in one go.
by ralmidani on 8/3/22, 2:04 PM
by game_the0ry on 8/3/22, 1:04 PM
I am sure a a lot of django devs will like it, but if I need the performance that I would get from going async, I would not being using django as my web framework.
FWIW I like django / python for a lot of things, just not for performance.
by buro9 on 8/3/22, 11:30 AM
by sirodoht on 8/3/22, 10:12 AM
by syastrov on 8/3/22, 5:28 PM
by ac130kz on 8/3/22, 1:48 PM