[ python-Bugs-1230540 ] sys.excepthook doesn't work in threads

SourceForge.net noreply at sourceforge.net
Wed Jun 6 13:11:28 CEST 2007


Bugs item #1230540, was opened at 2005-06-30 20:06
Message generated for change (Comment added) made by mwh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1230540&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Threads
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jonathan Ellis (ellisj)
Assigned to: Nobody/Anonymous (nobody)
Summary: sys.excepthook doesn't work in threads

Initial Comment:
simple script to reproduce:

import sys, threading

def log_exception(*args):
    print 'got exception %s' % (args,)
sys.excepthook = log_exception

def foo():
    a = 1 / 0
threading.Thread(target=foo).start()

Note that a normal traceback is printed instead of "got
exception."

----------------------------------------------------------------------

>Comment By: Michael Hudson (mwh)
Date: 2007-06-06 12:11

Message:
Logged In: YES 
user_id=6656
Originator: NO

I've just run into this, and it's very annoying.  The stupid part is that
threads started with the thread module don't have this problem, it's just a
problem with threading.Thread()s trying to be too clever.

I would vote for deleting all the code to do with exception printing in
threading.py and letting the C machinery take care of it.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1230540&group_id=5470


More information about the Python-bugs-list mailing list