CPython itself maintains a list of signal handles, defined as Handlers macro
signal.signal function (signal_signal_impl in C) modifies Handlers list (PyOS_setsig and PyOS_getsig take the responsibility to call signal function from <signal.h>).
then it passes signal_handler to PyOS_setsig for any callable.
Once a signal is raised, signal_handler will be called,
in which trip_signal is called, setting tripped flag.
Then who does the call to the callable?
It’s _PyErr_CheckSignalsTstate
which checks all signalnum in 1..<Py_NSIG, calling its installed callable whose tripped == 1
How is that function above called?
PyErr_CheckSignals (declared in pyerrors.h, called manually )handle_signals from Python/ceval_gil.c← _PyEval_MakePendingCalls ← Py_MakePendingCalls