#36863: Under WSGI, multiple calls to asgiref.sync.async_to_sync within the same
request do not share the same event loop.
-------------------------------------+-------------------------------------
Reporter: Mykhailo Havelia | Owner: Vishy
Type: | Algo
Cleanup/optimization | Status: new
Component: HTTP handling | Version: 6.0
Severity: Normal | Resolution:
Keywords: async, wsgi | Triage Stage:
| Someday/Maybe
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mykhailo Havelia):
Replying to [comment:14 Jacob Walls]:
> I want to help you advance the django-async-backend
I really appreciate that, thank you so much βΊοΈ
> I could be not understanding the intended audience of testers. Can't we
test this with daphne's runserver?
We have a fairly large Django project that was set up long before async
support existed. Part of it is now async (separate API endpoints), but a
big portion is still fully sync. For development, we run everything
through a single server so the whole system works together in one place.
Technically, yes. I could run async parts with Uvicorn/Gunicorn and keep
the rest elsewhere. But then we'd need:
- two dev servers
- plus something to sit in front and combine them
- and both servers would need restarting on code changes
That makes the dev setup more complex and increases the barrier for other
teams. Just running the backend requires extra infrastructure and
configuration, which grows over time.
A concrete example is async Redis usage. It works fine under ASGI, but
under WSGI we hit real limitations:
- connections can't be shared properly across requests
- we can't reliably close them at the end of the request because the
expected async lifecycle and signals don't behave the same way
ASGI only sounds easy, but with a unified dev setup this is exactly where
problems show up.
> So that supports the idea that we would eventually get around to your
proposal
DEP 0009 is 6 years old already π
still waiting. a bit ironic.
> but since DEP 0009 there have been other conversations to the effect of,
"aren't we basically done except for the async database backend."
I kind of wish that were true π From my side, there's still a lot of work
left
> And if that's ASGI-only for now, that might be enough?
In practice, a lot of internal Django code still ends up going through
async - sync bridges. People wrap things in `sync_to_async` and assume
they're writing fully async code. This is a really remarkable thread on
this topic https://forum.djangoproject.com/t/asynctestclient/43841π
> I can check my understanding with the Steering Council early next week.
Setting Someday/Maybe until then.
thank you so much π
btw: If you need any more info, just message me anytime.
--
Ticket URL: <https://code.djangoproject.com/ticket/36863#comment:15>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019c100e3029-dcbbe826-8815-4d63-a408-016d794f984a-000000%40eu-central-1.amazonses.com.