MCPcopy Index your code
hub / github.com/RustPython/RustPython / enter_async_context

Method enter_async_context

Lib/contextlib.py:654–670  ·  view source on GitHub ↗

Enters the supplied async context manager. If successful, also pushes its __aexit__ method as a callback and returns the result of the __aenter__ method.

(self, cm)

Source from the content-addressed store, hash-verified

652 return _exit_wrapper
653
654 async def enter_async_context(self, cm):
655 """Enters the supplied async context manager.
656
657 If successful, also pushes its __aexit__ method as a callback and
658 returns the result of the __aenter__ method.
659 """
660 cls = type(cm)
661 try:
662 _enter = cls.__aenter__
663 _exit = cls.__aexit__
664 except AttributeError:
665 raise TypeError(f"'{cls.__module__}.{cls.__qualname__}' object does "
666 f"not support the asynchronous context manager protocol"
667 ) from None
668 result = await _enter(cm)
669 self._push_async_cm_exit(cm, _exit)
670 return result
671
672 def push_async_exit(self, exit):
673 """Registers a coroutine function with the standard __aexit__ method

Calls 1

_push_async_cm_exitMethod · 0.95