wsgi silently swallows errors

Graham Dumpleton Graham.Dumpleton at gmail.com
Mon Jan 19 23:06:28 CET 2009


On Jan 20, 8:03 am, Jean-Paul Calderone <exar... at divmod.com> wrote:
> On Mon, 19 Jan 2009 12:15:29 -0800, Ron Garret <rnospa... at flownet.com> wrote:
> >Consider the following wsgi app:
>
> >def application(env, start_response):
> >  start_response('200 OK',[('Content-type','text/plain')])
> >  yield "hello"
> >  x=1/0
> >  yield "world"
>
> >The result of this is that the web browser displays "hello" and an error
> >message ends up in the web log.  But there is no other indication that
> >an error has occurred.
>
> >Is there any way to get WSGI to not silently swallow errors that occur
> >after start_response has been called?
>
> WSGI is a specification, not a piece of software.  The specification isn't
> swallowing the error, some piece of software is.  What WSGI container are
> you using?

Not Apache/mod_wsgi at least, as message would show in Apache error
logs.

[Tue Jan 20 09:03:19 2009] [info] [client ::1] mod_wsgi (pid=271,
process='wsgi', application='dangermouse:8224|/wsgi/scripts/
swallow.py'): Loading WSGI script '/usr/local/wsgi/scripts/swallow.py'
[Tue Jan 20 09:03:19 2009] [error] [client ::1] mod_wsgi (pid=271):
Exception occurred processing WSGI script '/usr/local/wsgi/scripts/
swallow.py'
[Tue Jan 20 09:03:19 2009] [error] [client ::1] Traceback (most recent
call last)
[Tue Jan 20 09:03:19 2009] [error] [client ::1]   File "/usr/local/
wsgi/scripts/swallow.py", line 7, in application[Tue Jan 20 09:03:19
2009] [error] [client ::1]     x=1/0
[Tue Jan 20 09:03:19 2009] [error] [client ::1] ZeroDivisionError:
integer division or modulo by zero

Would just need to make sure you look in the correct log if have
virtual host specific error logs.

Graham




More information about the Python-list mailing list