python / python/cpython

Improve `__repr__` string of synchronize tools in the `multiprocessing` module.

オープン
#155,092 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。