Python contextlib.AbstractAsyncContextManager() Examples

The following are 2 code examples of contextlib.AbstractAsyncContextManager(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module contextlib , or try the search function .
Example #1
Source File: context.py    From aiotools with MIT License 5 votes vote down vote up
def __subclasshook__(cls, C):
            if cls is AbstractAsyncContextManager:
                if (any('__aenter__' in B.__dict__ for B in C.__mro__) and
                    any('__aexit__' in B.__dict__ for B in C.__mro__)):
                    return True
            return NotImplemented 
Example #2
Source File: context.py    From aiotools with MIT License 5 votes vote down vote up
def __init__(self,
                 context_managers: Optional[Iterable[AbstractAsyncContextManager]] = None):  # noqa
        self._cm = list(context_managers) if context_managers else []
        self._cm_yields: List[asyncio.Task] = []
        self._cm_exits: List[asyncio.Task] = []