#36714: Async signals lose ContextVar state due to use of asyncio.gather
----------------------------------+------------------------------------
Reporter: Mykhailo Havelia | Owner: (none)
Type: Bug | Status: new
Component: HTTP handling | Version: dev
Severity: Normal | Resolution:
Keywords: asyncio, signals | Triage Stage: Accepted
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:10 Carlton Gibson]:
> I continue to think that it would be a shame to not at least try to
maintain the concurrent signal dispatch here. We should be able to pass
the current context to the sync_send task, using the context parameter,
AFAICS. I'd like us to at least try that. If there's some blocking reason
why that's not feasible then (sure) we can look at running the sync
signals first.
This would require changes to `sync_to_async`. It might look something
like:
{{{
context = contextvars.copy_context()
@sync_to_async(context=ctx)
def foo():
...
}}}
If this approach is acceptable, I can prepare an MR.
--
Ticket URL: <https://code.djangoproject.com/ticket/36714#comment:11>
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/0107019a6d502d01-6696bf92-205a-4ebb-8d39-d0c798f42746-000000%40eu-central-1.amazonses.com.