python / python/cpython

_PyOS_SigintEvent() is needed for interruptible waiting on main thread

未关闭
#128,684 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

topic-C-API type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug report

Bug description:

Moved from https://github.com/python/cpython/pull/108605#issuecomment-2521215855

In https://github.com/python/cpython/pull/108605, _PyOS_SigintEvent was removed from the public headers.

TensorStore relies on that function here: https://github.com/google/tensorstore/blob/eda046b10158e7d82fdb0f23aeecdfdeb8ac5aa3/python/tensorstore/future.cc#L105 to enable synchronously blocking on the readiness of a custom Future type while allowing Ctrl+C to interrupt when running on the main thread.

The current workaround is to manually declare the function since the symbol is still available.

I'm not aware of a usable alternative. Since signal.set_wakeup_fd only allows a single fd to be set globally, it isn't usable from a library. The best alternative would probably be to poll by waking up every few hundred milliseconds.

CPython versions tested on:

3.13

Operating systems tested on:

No response

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先检查 CPython PR #108605,以及 TensorStore 的 python/tensorstore/future.cc 第 105 行中对 _PyOS_SigintEvent 的使用。跟踪移除公共头文件声明会如何影响扩展库,并比较可用的信号唤醒替代方案。完成的标准是为库提供一种受支持的方式,使其能够中断主线程上的同步等待,同时保留 Ctrl+C 的行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
api, operating-systems
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。