@contextlib.contextmanager
def _nested(*managers):
    exits = []
    vars = []
    exc = (None, None, None)
    try:
        for mgr in managers:
            exit = mgr.__exit__
            enter = mgr.__enter__
            vars.append(enter())
            exits.append(exit)
        yield vars
    except:
        exc = sys.exc_info()
    finally:
        while exits:
            exit = exits.pop()
            try:
                if exit(*exc):
                    exc = (None, None, None)
            except:
                exc = sys.exc_info()
        if exc != (None, None, None):
            # Don't rely on sys.exc_info() still containing
            # the right information. Another exception may
            # have been raised and caught by an exit method
            raise exc
Get current page
dataset/ETHPy150Open felipecruz/zmqpy/zmqpy/eventloop/stack_context.py/_nested--crossover with--dataset/ETHPy150Open DoubleCiti/daimaduan.com/daimaduan/utils/pagination.py/get_page