Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Waitress needs clear error message on no WSGI app #60

wants to merge 1 commit into from


Copy link

If a WSGI application was not passed to waitress, no errors are raised during server start up and only a confusing error message in the output (and nothing useful in the HTTP response). This request improves the error message in the log.

While this may seem unnecessary, it is a very easy beginner mistake to use this code in your Pyramid app:

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application."""
    config = Configurator(settings=settings)
    config.make_wsgi_app() # YIKES forgot return keyword 

The result of running the site with the missing return value is an error basically like this:

pserve /site/development.ini
Starting server in PID 7817.
serving on
2014-05-04 16:45:51,285 ERROR [waitress][Dummy-1] Exception when serving /
Traceback (most recent call last):
  File "/Users/mkennedy/programming/github/waitress/waitress/", line 337, in service
  File "/Users/mkennedy/programming/github/waitress/waitress/", line 173, in service
  File "/Users/mkennedy/programming/github/waitress/waitress/", line 396, in execute
    app_iter =, start_response)
TypeError: 'NoneType' object is not callable

That is entirely non-debuggable and non-googlable. With my proposed change, you'll see:

  File "/Users/mkennedy/programming/github/waitress/waitress/", line 393, in execute
    raise Exception("Cannot process request (WSGI application missing). "
Exception: Cannot process request (WSGI application missing). Was None pass where WSGI application was expected?

I think this is much more helpful.

I originally tried to verify this on server start rather than first request. But so many of the unit tests pass None for app that I decided it wasn't worth the trouble.

If a WSGI application was not passed to waitress, no errors are raised
and only confusing error messages are the result. This improves the
error message.
@mcdonc mcdonc closed this in 77698fb Jul 14, 2014
Copy link

mcdonc commented Jul 14, 2014

Thanks. I did not use your pull request, but I've added the feature a different way.

Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants