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


Groups > comp.lang.python > #74124

Re: thread.interrupt_main() behaviour

References <CAJV9OM9EfaystFNUtQJLapwP7yUhnjinduS=K8HDj2_BL9ys-Q@mail.gmail.com> <CANc-5UyZVHncY19vL9FYo8EV2s-PLJsTT=aA9uHp5Ez0DGOYkg@mail.gmail.com> <CALwzid=9LU2Bw-tcnbc2CERZSFm6P=nETMZEW7aztbVaiuBQnQ@mail.gmail.com> <CAJV9OM9kxht8uN=YngtK7X+59engVg-jvOwh4fcHxbH=nJP7qA@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2014-07-07 10:30 -0600
Subject Re: thread.interrupt_main() behaviour
Newsgroups comp.lang.python
Message-ID <mailman.11600.1404750702.18130.python-list@python.org> (permalink)

Show all headers | View raw


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

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


Thread

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

csiph-web