Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!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.070 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'subject:not': 0.03; '22,': 0.09; 'steps:': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'thread': 0.14; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 's/he': 0.16; 'subject:user': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'variable': 0.18; 'cc:addr:python.org': 0.22; 'error': 0.23; "aren't": 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'query': 0.26; 'least': 0.26; 'header:In- Reply-To:1': 0.27; '[1]': 0.29; 'important.': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'program,': 0.31; 'safely': 0.31; 'sep': 0.31; 'terminate': 0.31; 'running': 0.33; 'subject:the': 0.34; "i'd": 0.34; "can't": 0.35; 'connection': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'done': 0.36; 'should': 0.36; 'step': 0.37; 'being': 0.38; 'handle': 0.38; 'pm,': 0.38; 'signal': 0.60; 'traffic': 0.61; 'simply': 0.61; "you're": 0.61; 'show': 0.63; 'close': 0.67; 'internet': 0.71; 'cut': 0.74; 'costly': 0.84; 'free?': 0.84; 'gone.': 0.84; 'shutdown': 0.84; 'visually': 0.84; 'afford': 0.91; 'divided': 0.91; 'to:none': 0.92; 'imagine': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=JHvbP6oj5s6N5XVx2Rz3OE5zd+BtFUvuYrjDnFHIk0Q=; b=aFVskeM2wtKTXl2R4IhosH9PleutaCAW0XReaS+olHgjLQ62HyUaLJsNmsGsWdDY4W Y6NcTJSfsQOTnkeE5mf3xTVYwXkL5lUC7StTGZjfTzGuYo+ddW0kse/eSE3N1Y7uaiXG WBl+Oy0n3WDs1UDiObX6pxwIUddfVnQOUuMvGv6m9hnhObROijGzhPfcFXrut51We3Gw klnx+pbYUfXSoFOGskU/rRm6LQQdKNYXqoJ8zur6EwNuYy6BAr2EvCLH+sVAzYwViM49 mc/aXX8FWxSTg6+0qPAxPkC+ezQZdXm8EbjmC/4OJ3tmfBrMnm67k7lYoCNjA4KmEe+H 2QDQ== MIME-Version: 1.0 X-Received: by 10.50.117.65 with SMTP id kc1mr13967072igb.34.1411386998047; Mon, 22 Sep 2014 04:56:38 -0700 (PDT) In-Reply-To: <6dffdfb3-82b3-4746-8f39-d6bfa727f439@googlegroups.com> References: <6dffdfb3-82b3-4746-8f39-d6bfa727f439@googlegroups.com> Date: Mon, 22 Sep 2014 21:56:37 +1000 Subject: Re: How to not enable a user to close the root tkinter window From: Chris Angelico Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1411387007 news.xs4all.nl 2940 [2001:888:2000:d::a6]:41942 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78137 On Mon, Sep 22, 2014 at 9:43 PM, Nicholas Cannon wrote: > Or can I safely stop the running threads and make them drop everything error free? This would be what I'd recommend. If someone wants to close your program, s/he should be allowed to - imagine if internet traffic is costly [1] and the query was done accidentally. So what you need is to have the shutdown divided into three steps: 1) Close the window, or at least show visually that it's shutting down. 2) Send a signal to the worker threads 3) When the worker threads all shut down, terminate the program. You can handle step 3 simply by ensuring that the threads aren't marked as daemons. Python won't shut down until they're all gone. Step 1 is, I suspect, already happening. So all you need to do is message the worker thread - and that can be done simply by setting a global variable or something. However, I'm not seeing any use of threads in your code. What thread is being cut off? What's the error you're seeing? ChrisA [1] "costly" might not mean money, although it can. But imagine you're on a slow connection and you can't afford to have other programs lagging out something that's important.