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)
| 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 |