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

Method push_async_exit

Lib/contextlib.py:672–688  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 3

test_async_pushMethod · 0.80

Calls 2

_push_async_cm_exitMethod · 0.95
_push_exit_callbackMethod · 0.80

Tested by 3

test_async_pushMethod · 0.64