#36714: Async signals lose ContextVar state due to use of asyncio.gather
----------------------------------+------------------------------------
Reporter: Mykhailo Havelia | Owner: (none)
Type: Uncategorized | 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
----------------------------------+------------------------------------
Changes (by Carlton Gibson):
* cc: Carlton Gibson (added)
* stage: Unreviewed => Accepted
Comment:
Hi Mykhailo.
Thanks for the report. (And thanks for writing it up so nicely.)
> We can try using contextvars.copy_context() to preserve and share the
same context between tasks and signal handlers.
So, yes — passing the `context` explicitly to the tasks would be my first
thought. The whole idea of that API is to allow control over this, when
trying to keep things ''structured'', no?
Then we should resolve #36315 first no? TaskGroup is the newer preferred
API. Do you fancy reviewing that?
I'd be a bit sad if we had to lose the concurrent async dispatch on
signals. (I grant your point that it may not be a big gain in performance
necessarily, but ... 🙂 )
--
Ticket URL: <https://code.djangoproject.com/ticket/36714#comment:1>
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/0107019a58e48cb0-ca67058f-e313-4a4d-9110-eb2925fe5cd7-000000%40eu-central-1.amazonses.com.