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: 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>': 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 To: =?UTF-8?Q?Ervin_Heged=C3=BCs?= Content-Type: multipart/alternative; boundary=089e013c69be33e6dd0501b0d474 Cc: Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --089e013c69be33e6dd0501b0d474 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, Aug 27, 2014 at 1:55 PM, Ervin Heged=C3=BCs wro= te: > 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 --089e013c69be33e6dd0501b0d474 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On Wed, Aug 27, 2014 at 1:55 PM, Ervin Heged=C3=BCs <<= a href=3D"mailto:airween@gmail.com" target=3D"_blank">airween@gmail.com= > wrote:
what's the correct way to terminate a th= read by itself?

If this is something you need to do a= s a regular course of business, I'd share a Queue between the main thre= ad and the target thread. When you want it to exit, shoot it a command to d= o 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-daemo= n threads alive, the program will exit.

Skip
<= div class=3D"gmail_extra">
--089e013c69be33e6dd0501b0d474--