Skip to content

Tag: python-contextvars

Factory for contextvar default value

Setting a dictionary as ContextVar default: …kinda works, as the dictionary will be available as default, but it always references the same instance, instead of generating a new one for each context. Do contextvars somehow support factories (for dicts, lists, and alike), as in: Or do I just have to do i…