Is it safe to call `print` in a Python signal handler?
Summary
The article examines the safety of calling print inside a Python signal handler. It explains CPython’s model where signal callbacks run outside the low-level handler and warns about reentrancy. A stress test demonstrates that printing from a signal handler can lead to a RuntimeError under extreme conditions, concluding that non-trivial work in signal handlers should be avoided.