Theme 1 – Signal handling is notoriously tricky, especially with threads or event loops
- IgorPartola: “What’s really fun is mixing signal handling and threads, especially on Linux. There is a simple way to do it and about a thousand ways that include at least one gotcha.”
- Uptrenda: “And when you combine it with event loops and multiple OSes + python versions it gets even more difficult.”
- jrumbut: “If you put a print statement in the handler, you can get this result.”
Theme 2 – POSIX signals are fundamentally unsafe; alternatives like signalfd or self‑pipe are needed
- nine_k: “POSIX signals are broken by design, alas: https://lwn.net/Articles/414618/ Python or not, almost nothing is safe inside a signal handler.”
- inigyou: “The ones related to application logic must only be handled with signalfd if you want any semblance of reliability.”
- charcircuit: “Signals should just come in via a new thread and it would solve all the complexity around them.”
- inigyou: “They should come in via signalfd unless they're the moral equivalent of a non‑maskable interrupt.”
Theme 3 – Python’s signal handling works via a flag‑based deferral, which changes the safety picture but doesn’t eliminate problems
- knome: “the first line of the article points out that python isn't run in the POSIX C handler. that just sets a flag for the interpreter to act on. the python issue is an unsafe re‑entrant handling strategy in the interpreter.”
- megagpt3: “He considers it safe if it's unlikely to crash? That's also true in C. Calling printf in a C signal handler is likely to work. So why does he consider it important in C but 'not a practical consideration' in Python?”