How to stop a specific thread in Python 2.7?

Liste des GroupesRevenir à cl python 
Sujet : How to stop a specific thread in Python 2.7?
De : mk1853387 (at) *nospam* gmail.com (marc nicole)
Groupes : comp.lang.python
Date : 25. Sep 2024, 19:24:49
Autres entêtes
Message-ID : <mailman.7.1727285081.2990.python-list@python.org>
References : 1
Hello guys,

I want to know how to kill a specific running thread (say by its id)

for now I run and kill a thread like the following:
# start thread
thread1 = threading.Thread(target= self.some_func(), args=( ...,), )
thread1.start()
# kill the thread
event_thread1 = threading.Event()
event_thread1.set()

I know that set() will kill all running threads, but if there was thread2
as well and I want to kill only thread1?

Thanks!

Date Sujet#  Auteur
25 Sep 24 * How to stop a specific thread in Python 2.7?3marc nicole
25 Sep 24 `* Re: How to stop a specific thread in Python 2.7?2Stefan Ram
25 Sep 24  `- Re: How to stop a specific thread (Posting On Python-List Prohibited)1Lawrence D'Oliveiro

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal