Pylons/pyramid_debugtoolbar

Latest version is not working with Google App Engine

magoarcano opened this issue · 4 comments

Hi
Since the 4.x it's not working for Google App Engine development server, because now it doesn't accept a multiprocess environment.
I get the message:

/pyramid_debugtoolbar/toolbar.py:214: UserWarning: pyramid_debugtoolbar has detected that the application is being served by a forking / multiprocess web server. The toolbar relies on global state to work and is not compatible with this environment. The toolbar will be disabled

Version 3.0.5 was working great.

That warning is correct. The debugtoolbar never worked with a forking/multiprocess web server because you would only see some of the requests/some of the items to debug because a request may or may not be scheduled on the same process.

Unfortunately this is not a use case we support. If you are absolutely sure that the GAE development server does not fork and is not multi-process, you may want to write a small WSGI middleware that removes the flag set on the WSGI environment that says it is.

Thanks.

If I hack the code a little I can make it work for GAE.

First I comment that block of code:

#         if request.environ.get('wsgi.multiprocess', False):
#             warnings.warn(
#                 'pyramid_debugtoolbar has detected that the application is '
#                 'being served by a forking / multiprocess web server. The '
#                 'toolbar relies on global state to work and is not compatible '
#                 'with this environment. The toolbar will be disabled.')
#             return handler(request)

Secondly, I have to bypass process_response_deferred() at headers.HeaderDebugPanel (new in version 4.x):

def finished_callback(request):
            pass

And finally VersionDebugPanel (also in version 3.x):

def _get_platform_name(self):
        return "platform.platform() para GAE" #platform.platform()

Maybe it's not working 100% ok because it's multiprocess server. For now it's enough for me.

Theoretically there is a way for serializing the requests by disabling the dev_appserver multi-threading and multi-processing support, with a flag. I will try it.

multi-threading is fine. multi-processing does not work correctly with the debugtoolbar.

I guess I agree that the warning is helping you discover that GAE is possibly breaking the toolbar in subtle ways. However I don't see any reason your fixes for the header and versions panels are required so I don't fully understand your issue.

If you can stop GAE from running with multiple processes and then open actual issues with the panel as a result then we should try to fix them. Until then there's nothing I can do on my end.