Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #196750

How to stop a specific thread in Python 2.7?

From marc nicole <mk1853387@gmail.com>
Newsgroups comp.lang.python
Subject How to stop a specific thread in Python 2.7?
Date 2024-09-25 19:24 +0200
Message-ID <mailman.7.1727285081.2990.python-list@python.org> (permalink)
References <CAGJtH9RBmcofpg5ifiXZm4z8XRBQkGVzDSduR7=9QH75-Ubpgw@mail.gmail.com>

Show all headers | View raw


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!

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

How to stop a specific thread in Python 2.7? marc nicole <mk1853387@gmail.com> - 2024-09-25 19:24 +0200
  Re: How to stop a specific thread (Posting On Python-List Prohibited) Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-09-25 21:42 +0000

csiph-web