MCPcopy
hub / github.com/pallets/click / call_on_close

Method call_on_close

src/click/core.py:673–683  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 4

convertMethod · 0.80
cliFunction · 0.80
set_stateMethod · 0.80
set_levelMethod · 0.80

Calls

no outgoing calls

Tested by 3

cliFunction · 0.64
set_stateMethod · 0.64
set_levelMethod · 0.64