threading.Thread: Add start=False parameter to start immediately the thread
未关闭
还没有人认领这个 Issue。
stdlib
type-feature
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
It's common to create multiple threads, start them, and then join them. Example:
threads = [
threading.Thread(target=run_a),
threading.Thread(target=run_b),
]
for thread in threads:
thread.start()
...
for thread in threads:
thread.join()
I propose adding a start=False parameter to threading.Thread to start immediately the thread. The example would become:
threads = [
threading.Thread(target=run_a, start=True),
threading.Thread(target=run_b, start=True),
]
...
for thread in threads:
thread.join()
The new parameter would solve the old issue gh-93293 which requests to return self in start(). The issue example:
threads = []
for i in range(10):
thread = threading.Thread(target=fn, args=(i,))
thread.start()
threads.append(thread)
for t in threads:
t.join()
would become:
threads = [threading.Thread(target=fn, args=(i,), start=True) for i in range(10)]
for t in threads:
t.join()
Linked PRs
- gh-155335
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先检查 threading.Thread 构造函数以及 start() 和 join() 的行为,然后检查 gh-155335 中关联的工作。确定在构造期间启动的 API 语义和兼容性影响;当提议的用法能够正常工作且不改变现有 Thread 行为时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- operating-systems
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100