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


Groups > comp.lang.python > #74124 > unrolled thread

Re: thread.interrupt_main() behaviour

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2014-07-07 10:30 -0600
Last post2014-07-07 10:30 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: thread.interrupt_main() behaviour Ian Kelly <ian.g.kelly@gmail.com> - 2014-07-07 10:30 -0600

#74124 — Re: thread.interrupt_main() behaviour

FromIan Kelly <ian.g.kelly@gmail.com>
Date2014-07-07 10:30 -0600
SubjectRe: thread.interrupt_main() behaviour
Message-ID<mailman.11600.1404750702.18130.python-list@python.org>
On Mon, Jul 7, 2014 at 8:41 AM, Piyush Verma <114piyush@gmail.com> wrote:
> Thanks Ian for information. There is slightly more I want to do. Consider if
> I want to kill some threads not all, is there a way to do that?

You can't safely interrupt threads.  What you can do is *request* the
thread to terminate by setting a flag on it (perhaps using a
threading.Event object, but an ordinary bool attribute can also be
used), and then having the thread periodically check the state of the
flag and exit gracefully when requested.

For more detail, see:
http://stackoverflow.com/questions/323972/is-there-any-way-to-kill-a-thread-in-python

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web