I want to know how to kill a specific running thread (say by its id)
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?
On 25Sep2024 19:24, marc nicole <mk1853387@gmail.com> wrote:
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?
No, `set()` doesn't kill a thread at all. It sets the `Event`, and each thread must be checking that event regularly, and quitting if it becomes
set.
You just need a per-thred vent instead of a single Event for all the
threads.
Cheers,
Cameron Simpson <cs@cskk.id.au>
--
https://mail.python.org/mailman/listinfo/python-list
How to create a per-thread event in Python 2.7?
Hello guys,--- Synchronet 3.20a-Linux NewsLink 1.114
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!
--
https://mail.python.org/mailman/listinfo/python-list
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 994 |
Nodes: | 10 (0 / 10) |
Uptime: | 97:32:36 |
Calls: | 13,016 |
Calls today: | 2 |
Files: | 186,574 |
Messages: | 3,282,103 |