MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / sigint_handler

Method sigint_handler

cmd2/cmd2.py:2770–2794  ·  view source on GitHub ↗

Signal handler for SIGINTs which typically come from Ctrl-C events. If you need custom SIGINT behavior, then override this method. :param signum: signal number :param frame: the current stack frame or None

(
        self,
        signum: int,  # noqa: ARG002
        frame: FrameType | None,  # noqa: ARG002
    )

Source from the content-addressed store, hash-verified

2768 return [topic for topic in all_topics if topic not in self.hidden_commands and topic not in self.disabled_commands]
2769
2770 def sigint_handler(
2771 self,
2772 signum: int, # noqa: ARG002
2773 frame: FrameType | None, # noqa: ARG002
2774 ) -> None:
2775 """Signal handler for SIGINTs which typically come from Ctrl-C events.
2776
2777 If you need custom SIGINT behavior, then override this method.
2778
2779 :param signum: signal number
2780 :param frame: the current stack frame or None
2781 """
2782 if self._cur_pipe_proc_reader is not None:
2783 # Pass the SIGINT to the current pipe process
2784 self._cur_pipe_proc_reader.send_sigint()
2785
2786 # Check if we are allowed to re-raise the KeyboardInterrupt
2787 if not self.sigint_protection:
2788 raise_interrupt = True
2789 if self.current_command is not None:
2790 command_set = self.find_commandset_for_command(self.current_command.command)
2791 if command_set is not None:
2792 raise_interrupt = not command_set.sigint_handler()
2793 if raise_interrupt:
2794 self._raise_keyboard_interrupt()
2795
2796 def termination_signal_handler(self, signum: int, _: FrameType | None) -> None:
2797 """Signal handler for SIGHUP and SIGTERM. Only runs on Linux and Mac.

Callers

nothing calls this directly

Calls 3

send_sigintMethod · 0.80

Tested by

no test coverage detected