How to stop a specific thread in Python 2.7?

marc nicole mk1853387 at gmail.com
Wed Sep 25 13:24:49 EDT 2024


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!


More information about the Python-list mailing list