#31238 closed Uncategorized (invalid)
Django using ASGI server but translations uses thread local.
| Reported by: | Christopher Broderick | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Other) | Version: | 3.0 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Not sure if I am missing some magic somewhere but it seems to me that if I use an ASGI server for Django, then it is likely I will respond to a request with the wrong language in a multilingual website with simultaneous requests from users needing a different language since tranlations uses thread local to store the language:
https://github.com/django/django/blob/e3d0b4d5501c6d0bc39f035e4345e5bdfde12e41/django/utils/translation/trans_real.py#L25
If I am missing something, can someone enlighten me please?
Change History (2)
comment:1 by , 6 years ago
| Component: | Uncategorized → Core (Other) |
|---|---|
| Resolution: | → invalid |
| Status: | new → closed |
| Summary: | Django using ASGI server but translations uses thread local → Django using ASGI server but translations uses thread local. |
comment:2 by , 6 years ago
I have no personal experience with it, but as you can see in the file you mention, Local is no longer from the classical threading module but from asgiref.local, which should be async friendly.
We added ASGI server but it's just a first step of bringing async to Django. I agree that we should be clearer in what adding ASGI support really means (see documentation and DEP 0009: Async-capable Django). We accepted ticket #31182 to clarify this. Currently we're working on asynchronous views (see #31224).