Register a function to be called when the context tears down. This can be used to close resources opened during the script execution. Resources that support Python's context manager protocol which would be used in a ``with`` statement should be registered with :meth:
(self, f: t.Callable[..., t.Any])
| 671 | return self._exit_stack.enter_context(context_manager) |
| 672 | |
| 673 | def call_on_close(self, f: t.Callable[..., t.Any]) -> t.Callable[..., t.Any]: |
| 674 | """Register a function to be called when the context tears down. |
| 675 | |
| 676 | This can be used to close resources opened during the script |
| 677 | execution. Resources that support Python's context manager |
| 678 | protocol which would be used in a ``with`` statement should be |
| 679 | registered with :meth:`with_resource` instead. |
| 680 | |
| 681 | :param f: The function to execute on teardown. |
| 682 | """ |
| 683 | return self._exit_stack.callback(f) |
| 684 | |
| 685 | def close(self) -> None: |
| 686 | """Invoke all close callbacks registered with |