Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77155
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <airween@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'only,': 0.07; 'stops': 0.07; 'utf-8': 0.07; 'except:': 0.09; 'msg': 0.09; 'try:': 0.09; 'def': 0.12; 'thread': 0.14; 'greetings:': 0.16; 'main():': 0.16; 'msg)': 0.16; 'msg):': 0.16; 'raised,': 0.16; 'range(0,': 0.16; 'stdout': 0.16; 'subject:Thread': 0.16; 'exception': 0.16; 'module': 0.19; 'header:User-Agent:1': 0.23; 'correct': 0.29; 'raise': 0.29; "doesn't": 0.30; 'code': 0.31; 'terminate': 0.31; 'allows': 0.31; 'class': 0.32; 'skip:_ 10': 0.34; 'skip:s 30': 0.35; 'received:84': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'object,': 0.36; 'hi,': 0.36; 'handle': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'helps': 0.61; 'skip:t 30': 0.61; 'from:charset:utf-8': 0.61; 'content- disposition:inline': 0.62; 'itself?': 0.84; 'received:hu': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:content-transfer-encoding:user-agent; bh=YhFqw0L8yvbHF4DREx0WVu1JW55eKfZHbI3OELrDVOk=; b=0C3h8TINpp2MVg6HxQh/M0otPKXYWW0VI7yPdIUmC1m9L1vlvU/lOnXCDAgzB1sOcf m/cyU4Iez9tfYgOsCFONLftsOvBT1exS6sPD34WxvfRrInVFa1qH7f7GWEqoPyjEYlaG 1HPC2qET5qvPjmsQ8Z2GvfqiHUPdqLLnbCMiRkC/ce6ft2N3KQe4LjP5t5OOd2tBTqwD P17nSvH+9/aiZlxwmvDu7KD01b9xKOiIHxwB+59nbJbYlJiJWVa2KMhOhUpZ0VAvGdi+ dYYgyYzhRJpyrYBCEwwxHwbPN+M3uDHT30YLAiKMB8vUpVpgKz7TxiJVtR4Y5QEhl2XX gTQg== |
| X-Received | by 10.194.92.71 with SMTP id ck7mr38703539wjb.11.1409165716572; Wed, 27 Aug 2014 11:55:16 -0700 (PDT) |
| Date | Wed, 27 Aug 2014 20:55:14 +0200 |
| From | Ervin Hegedüs <airween@gmail.com> |
| To | python-list@python.org |
| Subject | Thread terminate |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Disposition | inline |
| Content-Transfer-Encoding | 8bit |
| User-Agent | Mutt/1.5.21 (2010-09-15) |
| 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.13520.1409165718.18130.python-list@python.org> (permalink) |
| Lines | 58 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1409165718 news.xs4all.nl 2891 [2001:888:2000:d::a6]:36580 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:77155 |
Show key headers only | View raw
Hi,
what's the correct way to terminate a thread by itself?
I mean:
class MyThread(threading.Thread):
def __init__(self, queueitem):
threading.Thread.__init__(self)
...
def run(self):
"""pseudo code below"""
try:
self.connect_to_database()
except:
self.terminate("Error when connect to db")
try:
self.create_db_table()
except:
self.terminate("Error when create table")
....
def terminate(self, msg):
self.error = True
self.errormsg = msg
syslog.syslog(syslog.LOG_DEBUG, msg)
raise Exception(msg)
in main():
for q in range(0, 10):
mt = MyThread()
try:
mt.run()
except:
mt.join()
but it doesn't works - the exception showed on stdout only, and
the thread stops of course, but I would like to handle the
exceptions. If I call the join() inside from thread object, then
an exception raised, cause the thread object of Threading module
doesn't allows that...
Any helps are welcome,
greetings:
a.
--
I � UTF-8
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Thread terminate Ervin Hegedüs <airween@gmail.com> - 2014-08-27 20:55 +0200
csiph-web