lisa.utils.ComposedContextManager#

class lisa.utils.ComposedContextManager(cms)[source]#

Bases: object

Compose context managers together.

Parameters:

cms (list(contextlib.AbstractContextManager or collections.abc.Callable)) – Context manager factories to compose. Each item can either be a context manager already, or a function that will be called to produce one.

Example:

with ComposedContextManager([cm1, cm2]):
    ...

# Equivalent to
with cm1() as _cm1:
    with cm2() as _cm2:
        ...

Methods

Methods#

ComposedContextManager.__enter__()[source]#
ComposedContextManager.__exit__(*args, **kwargs)[source]#