edc.ContextStack#
- class etils.edc.ContextStack(**kwargs)[source]
Bases:
Generic[etils.edc.stack._T]Local stack object (per-thread and contextvars-aware).
Each thread / coroutine will have its own stack. This ensure that contextmanagers from different threads do not conflict.
Usage:
_stack = edc.ContextStack[int]() @contextlib.contextmanager def my_thread_safe_contextmanager(): _stack.append(1) try: yield finally: _stack.pop()
- stack: Annotated[list[etils.edc.stack._T], <object object at 0x7fcbe0f38350>]
- append(value: etils.edc.stack._T) None[source]
Append a value to the stack.
- pop() etils.edc.stack._T[source]
Pop the last value from the stack.
- replace(
- **kwargs: Any,
Similar to dataclasses.replace.