I don’t understand why there is a
copy_context function in
contextvars but no
That means that changes made to “the context” inside a function that the context object (/vars) wasn’t passed to it explicitly aren’t reflected in the outer context. As it must be done on a copy of the old context.
In my case, they are complicated recursive functions. And I simply can’t pass additional parameters.
The entire handling of vars is cumbersome. Because, for some reason, Context doesn’t accept simply the name of the context var, and instead one needs to iterate over keys to get the right context var.
I wonder why is that and if there is anything to do to change this. Are we really afraid of functions doin unauthorized changes in the context? If so, can we have an attribute that allows for arbitrary changes in the context?
(Hopefully it is the right forum. It is not exactly usage discussing as there is simply no such option. So I wonder why.)