[Python-bugs-list] [ python-Feature Requests-618633 ] sys.execpthook not used in threads

noreply@sourceforge.net noreply@sourceforge.net
Sat, 05 Oct 2002 14:04:36 -0700


Feature Requests item #618633, was opened at 2002-10-04 18:24
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=618633&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: David Thiede (dthiede)
Assigned to: Nobody/Anonymous (nobody)
Summary: sys.execpthook not used in threads

Initial Comment:
The sys.excepthook feature does not seem to be used
when exceptions are triggered in threads. It does work
in the MainThread. It would be real nice if this
feature would extended to threads.

The only thing that I can find on the lists bug or
patch seems to be Ping's orginal patch and the followup
posts to that patch.

Redhat 7.3
Python 2.2

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

>Comment By: Martin v. Löwis (loewis)
Date: 2002-10-05 23:04

Message:
Logged In: YES 
user_id=21627

I see what you mean. Please ignore my previous comment.

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

Comment By: David Thiede (dthiede)
Date: 2002-10-05 19:44

Message:
Logged In: YES 
user_id=427491

There is no indication of a callback hook in the Thread
class. The source for threading.py shows a _print_exc handle
that I had tested. It is possible to override the name and
get most of the desired behaviour but there are problems.
The following code is from threading.__bootstrap()

_print_exc(file=s)
_sys.stderr.write("Exception in thread %s:\n%s\n" %
                       (self.getName(), s.getvalue()))

This still generates some output to standard error which is
not desireable. It is also a global setting which is not
what you implied. Your statement is that "each thread has a
hook" is certainly not apparent. in the code. This API is
also different than what is available globally in the sys
module.except() hook. I also checked the cgitb.py module and
it also does't handle threads, apparently. I realize that
there are other ways to handle intercepting and formatting
excetpion output but the callback scheme was so nice.

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

Comment By: Martin v. Löwis (loewis)
Date: 2002-10-05 11:50

Message:
Logged In: YES 
user_id=21627

Each thread has its own except hook, so you have to set it
for each thread. If it is set in a thread, it is also used
there.

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

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