每日 Harness 开源 · Source
返回本期 · Back to 2026-08-31

博客文章 · Blog Posts2026-08-31 · Monday, August 31, 2026

Is It Safe to Call Print in a Python Signal Handler?

iafisher.com原文 ↗

Is It Safe to Call Print in a Python Signal Handler?
文章拆解 signal handler 中调用 `print` 的风险:缓冲 I/O、锁和可被中断的运行时路径可能在重入时死锁、交错或丢消息。更稳妥的模式是处理器只设置标志,由主循环在安全点完成输出;这个小问题折射出异步信号与高级运行时之间的真实契约。
–浏览

评论 · Comments