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


Groups > comp.lang.python > #77208

Re: Thread terminate

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin.stu.neva.ru!newsfeed2.funet.fi!newsfeeds.funet.fi!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <skip.montanaro@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.022
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'exits': 0.09; 'cc:addr :python-list': 0.11; 'thread': 0.14; 'exit.': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'subject:Thread': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'wed,': 0.18; 'command': 0.22; 'aug': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'skip': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'message-id:@mail.gmail.com': 0.30; 'shoot': 0.31; 'terminate': 0.31; 'regular': 0.32; "i'd": 0.34; 'something': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'pm,': 0.38; 'course': 0.61; 'to:addr:gmail.com': 0.65; 'between': 0.67; 'business,': 0.83; 'itself?': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=b4YRrMM5BywVffMahseVgtbTVjEAq0YpJeS6Jq/YQUE=; b=oXfUXT+uTvw4zNqV9sWqa4oqY29zyNkTgYhSJvdw4I0lIjRy0W+bM2wPpJxDOMBRo6 fYR0gMhp0SPyGverM7CIgCiZ9FxZHQuX+BGhad4+ZFybUt+CM1OoLveirUKsvM30J/5i 3cVEpxfn8ONd5y23PmyONMsnOqkNt7G2vdSc06322GEJaFJus9pkcjsphSmrMTGi8mOe SBAIHi8aOnEb22O7pORvbtAX1VWiQ67MHVonxJnizFaHpM2OWPPVhQ6V+4nynMf5oyzo +MRRHzB47OewCLZr0NMkj0kNr3y8eiH8eiQyC8mGJ6jimwVrMnnnZG19eGTTNzkpVEM+ I9+Q==
MIME-Version 1.0
X-Received by 10.50.36.38 with SMTP id n6mr5529442igj.24.1409233869594; Thu, 28 Aug 2014 06:51:09 -0700 (PDT)
Sender skip.montanaro@gmail.com
In-Reply-To <20140827185514.GA18660@arxnet.hu>
References <20140827185514.GA18660@arxnet.hu>
Date Thu, 28 Aug 2014 08:51:09 -0500
X-Google-Sender-Auth iyG1k9BW4E-peVKgkl8O4UpLLSg
Subject Re: Thread terminate
From Skip Montanaro <skip@pobox.com>
To Ervin Hegedüs <airween@gmail.com>
Content-Type multipart/alternative; boundary=089e013c69be33e6dd0501b0d474
Cc Python <python-list@python.org>
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.13559.1409233872.18130.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1409233872 news.xs4all.nl 2959 [2001:888:2000:d::a6]:37438
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:77208

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Wed, Aug 27, 2014 at 1:55 PM, Ervin Hegedüs <airween@gmail.com> wrote:

> what's the correct way to terminate a thread by itself?


If this is something you need to do as a regular course of business, I'd
share a Queue between the main thread and the target thread. When you want
it to exit, shoot it a command to do so over the queue. If it's a worker
thread of some sort, set it as a daemon thread. When your main thread exits
and there are no other non-daemon threads alive, the program will exit.

Skip

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


Thread

Re: Thread terminate Skip Montanaro <skip@pobox.com> - 2014-08-28 08:51 -0500

csiph-web