threading.Thread: Add start=False parameter to start immediately the thread
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 77.2k
- Forks
- 35.9k
- Métriques de merge des PR
- Métriques de PR en attente
Description
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
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par examiner le constructeur de threading.Thread ainsi que le comportement de start() et join(), puis inspectez le travail associé dans gh-155335. Déterminez la sémantique de l’API et les implications en matière de compatibilité du démarrage pendant la construction ; le travail est considéré comme terminé lorsque l’utilisation proposée fonctionne correctement sans modifier le comportement existant de Thread.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- operating-systems
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 25/100