Path: csiph.com!eternal-september.org!feeder.eternal-september.org!gegeweb.org!news.redatomik.org!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'exit.': 0.09; 'exits': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'subject:skip:m 10': 0.09; 'threads,': 0.09; 'thread': 0.10; 'suggest': 0.15; '(but': 0.15; '...)': 0.16; 'cc:addr:lac': 0.16; 'cc:addr:openend.se': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'message-id:@fido.openend.se': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'recipe': 0.16; 'threads': 0.16; 'laura': 0.18; 'stick': 0.18; 'gui': 0.18; '2015': 0.20; 'cc:addr:python.org': 0.20; 'cc:2**1': 0.22; 'see:': 0.22; 'sep': 0.22; "doesn't": 0.26; 'fri,': 0.27; 'idea': 0.28; 'idea,': 0.29; 'queue': 0.29; 'received:se': 0.29; 'url:activestate': 0.29; 'cc:no real name:2**1': 0.29; 'posting': 0.32; 'maybe': 0.33; 'url:code': 0.34; 'could': 0.35; 'skip:> 10': 0.35; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'itself': 0.38; 'subject:-': 0.39; 'your': 0.60; 'close': 0.61; 'header :Message-Id:1': 0.61; 'header:In-reply-to:1': 0.84; 'stone': 0.84; 'subject:down': 0.84; 'url:recipes': 0.84; 'birthday': 0.91 To: "James Harris" cc: python-list@python.org, lac@openend.se From: Laura Creighton Subject: Re: Shutting down a cross-platform multithreaded app In-reply-to: References: <87zj0jd1ta.fsf@jester.gateway.sonic.net> Comments: In-reply-to "James Harris" message dated "Fri, 18 Sep 2015 20:09:19 +0100." MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8280.1442609436.1@fido> Date: Fri, 18 Sep 2015 22:50:36 +0200 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [82.96.5.2]); Fri, 18 Sep 2015 22:50:39 +0200 (CEST) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442609448 news.xs4all.nl 23757 [2001:888:2000:d::a6]:33048 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96835 In a message of Fri, 18 Sep 2015 20:09:19 +0100, "James Harris" writes: >> Set the daemon flag on the worker threads, so when the main thread >> exits, the workers also exit. > >Interesting idea, and I did not know that a *thread* could be a daemon. >Unfortunately, I think what you suggest would kill the threads stone >dead and not allow them to close connections. Can you stick your worker threads into a Queue. When the main thread exits have it tell the queue to clean itself up? see: http://code.activestate.com/recipes/82965-threads-tkinter-and-asynchronous-io/ The main thread doesn't have to be a gui ... (but the author of that recipe and I are now drunkly celebrating a birthday so maybe I ought not to be posting this idea ...) Laura