Assigning a function to sys.excepthook doesn't work in WSGI

Alexander Sh tak.govoril at gmail.com
Wed Feb 18 14:16:34 EST 2015


On Wednesday, February 18, 2015 at 7:52:19 PM UTC+3, Ian wrote:
> 
> sys.excepthook is called just before the interpreter exits due to an
> exception. In a mod_wsgi environment, having the interpreter exit just
> because of an exception would be undesirable. I don't know exactly
> what it's doing under the hood, but I would assume that the exception
> never makes it to sys.excepthook because the gateway itself is
> catching the exception in order to generate the 500 response.
> 
> > I looked through the documentation, but unable to find the answer. Are there any ways to handle uncaught by try..except exceptions under mod_wsgi?
> 
> Here is what PEP 3333 has to say about error handling:
> https://www.python.org/dev/peps/pep-3333/#error-handling

Thank you for your reply, it clarifies everything. 
Actually, I've missed that PEP in my studies.



More information about the Python-list mailing list