__init__¶
-
LayeredContext.
__init__
(wrapped_class: K, max_layers: Optional[int] = 1, fail: bool = False)[source]¶ Construct a
LayeredContext
instance, wrapping the context manager class instance or func:contextlib.contextmanager manager functionwrapped_class
.- Parameters
wrapped_class (K|object) – A context manager class or
contextlib.contextmanager()
manager function to wrapmax_layers (int) – Maximum layers of
(async) with
blocks before silently consuming further attempts to enter/exit the context manager forwrapped_class
fail (bool) – (default:
False
) WhenTrue
, will raiseNestedContextException
when anenter()
call is going to cause more thanmax_layers
context manager layers to be active.