This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: sys.execpthook not used in threads
Type: enhancement Stage:
Components: None Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: draghuram, dthiede, loewis
Priority: normal Keywords:

Created on 2002-10-04 16:24 by dthiede, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
d dthiede, 2002-10-04 16:24 test showing that except hook not used in threads
Messages (5)
msg53654 - (view) Author: David Thiede (dthiede) Date: 2002-10-04 16:24
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
msg53655 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-10-05 09:50
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.
msg53656 - (view) Author: David Thiede (dthiede) Date: 2002-10-05 17:44
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.
msg53657 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-10-05 21:04
Logged In: YES 
user_id=21627

I see what you mean. Please ignore my previous comment.
msg61592 - (view) Author: Raghuram Devarakonda (draghuram) (Python triager) Date: 2008-01-23 17:30
This is a duplicate of a more recently opened #1230540.
History
Date User Action Args
2022-04-10 16:05:43adminsetgithub: 37265
2008-01-23 17:30:08draghuramsetstatus: open -> closed
nosy: + draghuram
resolution: duplicate
messages: + msg61592
2002-10-04 16:24:49dthiedecreate