Documentation
In the [documentation for contextvars.ContextVar], there is the following warning:
Important: Context Variables should be created at the top module level and never in closures. Context objects hold strong references to context variables which prevents context variables from being properly garbage collected.
@kumaraditya303 and I talked about it and he claimed that this is not the case any more (that was at least my understanding) and ContextVars can be defined as class/instance attributes for example. If that's the case, we should probably update the docs. Otherwise, it might make sense to emphasize on it even more, now that ContextVars will be even more widely used due to free-threading.
Documentation
In the [documentation for
contextvars.ContextVar], there is the following warning:@kumaraditya303 and I talked about it and he claimed that this is not the case any more (that was at least my understanding) and
ContextVars can be defined as class/instance attributes for example. If that's the case, we should probably update the docs. Otherwise, it might make sense to emphasize on it even more, now thatContextVars will be even more widely used due to free-threading.