spawn_system_task should not propagate ContextVar state #289
Comments
Is this still relevant, given the ContextVar change? The system task context could potentially be reset to a regular context() rather than a copy_context() (if I understand the issue correctly), otherwise this can be closed. |
It's still as relevant as it was, just now it applies to The intuition is that a "system task" is a global resource that's not particularly associated with any task, so it shouldn't retain the context where it happened to be spawned. I think I was thinking about this in the context of #303, where the idea is to use system tasks to model the case where you want a single task to be part of multiple parts of the task tree at the same time; in this case it doesn't make sense for Given how contextvars are more general than a single system, I guess the way to do it would be to stash a copy somewhere of the context that |
Probably we should make
spawn_impl
have asystem_task
flag instead of its currentki_protection_enabled
flag. We already have to special case init as not inheriting TaskLocals, so this would remove that special case (since init is a system task).The text was updated successfully, but these errors were encountered: