Registers a coroutine function with the standard __aexit__ method signature. Can suppress exceptions the same way __aexit__ method can. Also accepts any object with an __aexit__ method (registering a call to the method instead of the object itself).
(self, exit)
| 670 | return result |
| 671 | |
| 672 | def push_async_exit(self, exit): |
| 673 | """Registers a coroutine function with the standard __aexit__ method |
| 674 | signature. |
| 675 | |
| 676 | Can suppress exceptions the same way __aexit__ method can. |
| 677 | Also accepts any object with an __aexit__ method (registering a call |
| 678 | to the method instead of the object itself). |
| 679 | """ |
| 680 | _cb_type = type(exit) |
| 681 | try: |
| 682 | exit_method = _cb_type.__aexit__ |
| 683 | except AttributeError: |
| 684 | # Not an async context manager, so assume it's a coroutine function |
| 685 | self._push_exit_callback(exit, False) |
| 686 | else: |
| 687 | self._push_async_cm_exit(exit, exit_method) |
| 688 | return exit # Allow use as a decorator |
| 689 | |
| 690 | def push_async_callback(self, callback, /, *args, **kwds): |
| 691 | """Registers an arbitrary coroutine function and arguments. |