Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77224
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.020 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'anyway.': 0.05; 'exception.': 0.09; 'exit': 0.09; 'cc:addr:python-list': 0.11; 'thread': 0.14; 'err:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'sorts': 0.16; 'subject:Thread': 0.16; 'exception': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'class': 0.32; 'run': 0.32; 'fri,': 0.33; 'actual': 0.34; 'maybe': 0.34; "i'd": 0.34; 'except': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'object,': 0.36; 'handle': 0.38; 'resource': 0.38; 'does': 0.39; 'though,': 0.39; 'sure': 0.39; 'catch': 0.60; 'entire': 0.61; "you're": 0.61; "you'll": 0.62; 'taking': 0.65; 'statement,': 0.68; 'snapshot': 0.84; 'to:none': 0.92 |
| 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=M1Ynx0RjXND/8m1YI+VYEGjkAaSgp6pS+wLpV7TzKaQ=; b=SugLUFeif5yeJirxJlogAzL51uxtk/fW5J/9fwwkH19Kng05YyLnBY1EZ5hXhoF0q7 boFOhq2NwwngXJBkFjOeYoHKS7O1PSjY6lFRznQ645e05YUON/VLoFlcjXN7E3EEWUC4 eCyP+WQ9EMamT7dvYsM3KiI8sEzMvcDJmRPtPh+omAGOnxYLI9+YLAIGRaNIfBWpbCYN AtpMNt/SnrMcZm4o/Zy5Uo4UMBKJgn2DtpWuzpQeG5nrQ/bMtAqgVXl+3tY+uCDiSK5E 6NldhKb6tdnySR+wGs7K6Srf7fsBPgSWDDTj0AKxrqr1lru7jxXvaiW0m4rfLIT5Kb4Z DP6w== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.176.169 with SMTP id cj9mr7010739igc.14.1409244170764; Thu, 28 Aug 2014 09:42:50 -0700 (PDT) |
| In-Reply-To | <CALvWhxv-WUO-i_XMcPQHxRwS7K5CX6hOCe7msLT5xd7GhV4bdQ@mail.gmail.com> |
| References | <20140827185514.GA18660@arxnet.hu> <CALvWhxsJW+pDKYnf9iZzRHsUg6V9wbNjp=3VqEjGSomez_WQEw@mail.gmail.com> <20140828085211.GC2887@arxnet.hu> <CALvWhxv-WUO-i_XMcPQHxRwS7K5CX6hOCe7msLT5xd7GhV4bdQ@mail.gmail.com> |
| Date | Fri, 29 Aug 2014 02:42:50 +1000 |
| Subject | Re: Thread terminate |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <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.13573.1409244178.18130.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1409244178 news.xs4all.nl 2840 [2001:888:2000:d::a6]:35670 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:77224 |
Show key headers only | View raw
On Fri, Aug 29, 2014 at 2:23 AM, Chris Kaynor <ckaynor@zindagigames.com> wrote: > If what you want is to make sure the error is not printed to stderr, you'll > just need to make sure the thread's run function does not exit with an > exception. The simpliest way to do that would be to wrap the entire thread's > run function in a try...catch statement, like so: > > class Thread(threading.Thread) > ... > except Exception as err: This is actually something where it may be appropriate to catch BaseException, since you are terminating the thread immediately anyway. If you get a KeyboardInterrupt or something, you'll catch it, log it, and end the thread. Note, though, that retaining the actual error object risks resource leakage. You glom onto all sorts of locals, via the backtrace. Unless you're going to handle the exception and then dispose of the whole thread object, I'd advise caution; maybe consider taking a textual snapshot of the backtrace. ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Thread terminate Chris Angelico <rosuav@gmail.com> - 2014-08-29 02:42 +1000
csiph-web