A voir également:
- Thread en python
- Citizen code python avis - Accueil - Outils
- Python est introuvable. exúcutez sans argument pour procúder ó l ✓ - Forum Python
- Mot secret python pix ✓ - Forum Python
- Ce programme est écrit en python il construit un mot secret ✓ - Forum Python
- Python par la pratique : 101 exercices corrigés pdf - Forum Python
5 réponses
Ton programme ne vérifie pas que les threads sont morts avant de quitter ( avec join() ).
Résultat: Une fois le thread principal terminé, le garbage collector commencer à nettoyer les objets alors qu'il y a encore des threads vivants, d'où les exceptions.
Résultat: Une fois le thread principal terminé, le garbage collector commencer à nettoyer les objets alors qu'il y a encore des threads vivants, d'où les exceptions.
Bonjour,
J'ai exactement le même problème, mais avec un système embarqué.
Le programme suivant :
import thread
def plop(pid):
print str(pid)
for i in range(6):
thread.start_new(plop,(i,))
Me donne :
[root@armadeus test_soft]# python test.py
0
1
Unhandled exception in thread started by
Error in sys.excepthook:
Original exception was:
Unhandled exception in thread started by
Error in sys.excepthook:
Original exception was:
Unhandled exception in thread started by
Error in sys.excepthook:
Original exception was:
Unhandled exception in thread started by
Error in sys.excepthook:
Original exception was:
Si quelqu'un à une idée ?
J'ai exactement le même problème, mais avec un système embarqué.
Le programme suivant :
import thread
def plop(pid):
print str(pid)
for i in range(6):
thread.start_new(plop,(i,))
Me donne :
[root@armadeus test_soft]# python test.py
0
1
Unhandled exception in thread started by
Error in sys.excepthook:
Original exception was:
Unhandled exception in thread started by
Error in sys.excepthook:
Original exception was:
Unhandled exception in thread started by
Error in sys.excepthook:
Original exception was:
Unhandled exception in thread started by
Error in sys.excepthook:
Original exception was:
Si quelqu'un à une idée ?
Merci,
Maintenant ça fonctionne.
Du coup je suis obligé d'utiliser le module threading et de faire une classe qui en hérite :
Maintenant ça fonctionne.
Du coup je suis obligé d'utiliser le module threading et de faire une classe qui en hérite :
import threading class MyThread(threading.Thread): def __init__(self,myId): self.myId = myId threading.Thread.__init__(self) def run(self): print str(self.myId) threads = [] for i in range(6): thread = MyThread(i) thread.start() threads.append(thread) for thread in threads: thread.join() print "end"
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question