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


Groups > comp.lang.python > #74124

Re: thread.interrupt_main() behaviour

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'that?': 0.05; 'attribute': 0.07; 'see:': 0.07; 'exit': 0.09; 'thread': 0.14; 'bool': 0.16; 'requested.': 0.16; 'threads.': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'all,': 0.19; 'slightly': 0.19; 'mon,': 0.24; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; '(perhaps': 0.31; 'ordinary': 0.31; 'safely': 0.31; 'terminate': 0.31; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'object,': 0.36; 'thanks': 0.36; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'ian': 0.60; 'more': 0.64; 'periodically': 0.68; 'jul': 0.74; 'interrupt': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=3jRwhfWFcYv0yYPKAAhxLx2bP75iN8hbDCAWAh06x5M=; b=cidBBx5kJ2UrtYBVQbRx4rJuydNR8MZ/iD+Nxx12cFgWabruIEJhNvS+HQTe3K9usH UCcmHaddpf2iik4nVJLeZGVC/0Zwv5jWZ+k8VKc0SiGr4GBPbJRljgpa3PsfzrS5hUQA 7zs+JjPgBc8hTZkEAIcFz2Kzkus3FB6DTbKkToQfFKaMZCxNSdgSXXtVYwPyAT7Rmxex 09LUaxn4+kgh/KQvdnhFrAIZ6Ax+Fo6srwmUE+L4v90U0vB+Os9iUx9g6hbj64aiAJIb vM9quyewIO6Dsn/Vj4OaSagXeFFp8+Dff28r80h8X6NquHtp585Cfw/uU+e/w7Pztc+I x/VQ==
X-Received by 10.69.17.66 with SMTP id gc2mr29840255pbd.90.1404750694521; Mon, 07 Jul 2014 09:31:34 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <CAJV9OM9kxht8uN=YngtK7X+59engVg-jvOwh4fcHxbH=nJP7qA@mail.gmail.com>
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 Mon, 7 Jul 2014 10:30:54 -0600
Subject Re: thread.interrupt_main() behaviour
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11600.1404750702.18130.python-list@python.org> (permalink)
Lines 12
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1404750702 news.xs4all.nl 2905 [2001:888:2000:d::a6]:35018
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:74124

Show key headers only | 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