Improve `__repr__` string of synchronize tools in the `multiprocessing` module.
未关闭
还没有人认领这个 Issue。
stdlib
topic-multiprocessing
type-feature
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Feature or enhancement
Proposal:
To be consistant with representation string of threading sychronize tools and in accordance with the discussion from the #149447 PR , the missing id information must be added in the __repr__ of the following synchronization classes:
Lock,Rlock,Semaphore,BoundedSemaphore,Condition.
and refactoring must be performed to these 2 classes:
Event,Barrier.
See some examples below:
import threading
import multiprocessing
print(threading.Semaphore(3))
print(multiprocessing.Semaphore(3))
print(threading.Lock())
print(multiprocessing.Lock())
print(threading.Event())
print(multiprocessing.Event())
print(threading.Barrier(2))
print(multiprocessing.Barrier(2))
The ouput is:
<threading.Semaphore at 0x10378c8a0: value=3>
<Semaphore(value=3)>
<unlocked _thread.lock object at 0x103612040>
<Lock(owner=None)>
<threading.Event at 0x10378ccc0: unset>
<Event at 0x10378ccc0 unset>
<threading.Barrier at 0x10378ccc0: waiters=0/2>
<multiprocessing.synchronize.Barrier at 0x10378ccc0: waiters=0/2>
A PR will be published soon.
cc @gpshead
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
#149447
Linked PRs
- gh-155593
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 multiprocessing 模块中的 Lock、Rlock、Semaphore、BoundedSemaphore、Condition、Event 和 Barrier 类开始,将它们的表示形式与 threading 以及 #149447 中的讨论进行比较。完成的标准是:为列出的同步工具包含所请求的 id 信息,并对 Event 和 Barrier 进行所提议的重构;注意,PR #155593 已经在 issue 中关联。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- operating-systems
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100