python / python/cpython

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

Aberta
#155,092 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

stdlib topic-multiprocessing type-feature
Linguagem predominante
Python
Estrelas
77.2k
Forks
36k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece no módulo multiprocessing com as classes Lock, Rlock, Semaphore, BoundedSemaphore, Condition, Event e Barrier, comparando suas representações com threading e com a discussão em #149447. Considera-se concluído quando as informações de id solicitadas estiverem incluídas para as ferramentas de sincronização listadas e Event e Barrier receberem o refactoring proposto; observe que PR #155593 já está vinculado na issue.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
operating-systems
Tipo de issue
Funcionalidade
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.