Query : sys.excepthook exception in Python

Peter Hansen peter at engcorp.com
Mon Apr 10 11:08:10 EDT 2006


Pramod, TK wrote:
> Sometimes during execution of python scripts below mentioned error 
> string is displayed on the console.
> 
> *"Unhandled exception in thread started by  Error in sys.excepthook:  *
> *Original exception was:"*
> 
> The scripts are not terminated, they continue to execute normally.

Are you certain they are not terminated?  I've only ever seen this when 
the entire application was shutting down, and "daemon" threads which 
were still running (as they do right up until almost the moment the 
process exits) are going nuts because of the shutdown/cleanup processing 
of the interpreter.  (The key item is that at one stage the interpreter 
walks through all loaded modules, rebinding all global names in each one 
to None, and this causes havoc in most code.  The exceptions that are 
raised cannot be displayed successfully either, for the same reason, 
resulting in what you see above.)

I've also seen this in CherryPy in "development" mode, because it is 
shutting down and restarting, so although it doesn't look like it 
terminated, in effect the problem is the same.

-Peter




More information about the Python-list mailing list