MCPcopy
hub / github.com/pallets/werkzeug / __init__

Method __init__

src/werkzeug/local.py:54–62  ·  view source on GitHub ↗
(self, context_var: ContextVar[dict[str, t.Any]] | None = None)

Source from the content-addressed store, hash-verified

52 __slots__ = ("__storage",)
53
54 def __init__(self, context_var: ContextVar[dict[str, t.Any]] | None = None) -> None:
55 if context_var is None:
56 # A ContextVar not created at global scope interferes with
57 # Python's garbage collection. However, a local only makes
58 # sense defined at the global scope as well, in which case
59 # the GC issue doesn't seem relevant.
60 context_var = ContextVar(f"werkzeug.Local<{id(self)}>.storage")
61
62 object.__setattr__(self, "_Local__storage", context_var)
63
64 def __iter__(self) -> t.Iterator[tuple[str, t.Any]]:
65 return iter(self.__storage.get({}).items())

Callers 1

__init__Method · 0.45

Calls 1

__setattr__Method · 0.45

Tested by

no test coverage detected