Uh, that Examples section calls print inside the signal handler. Python's IO stack is non-reentrant. I hope nobody follows these examples and gets exceptions at runtime because of it.
The low-level C handler set the flag then returns. Only some time later does the Python run-time call the associated Python handler that you see in the Examples section.
https://github.com/python/cpython/blob/5f7aba938cf5007b6f954...
Here's even a test for it: https://github.com/python/cpython/blob/5f7aba938cf5007b6f954...