Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Description
Documentation
In the [documentation forcontextvars.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) andContextVar
s 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 thatContextVar
s will be even more widely used due to free-threading.
Metadata
Metadata
Assignees
Projects
Status