Skip to content

Commit

Permalink
Merge pull request #286 from mmerickel/warn-on-multiprocess
Browse files Browse the repository at this point in the history
add a warning when the wsgi server is multiprocess
  • Loading branch information
mmerickel authored Apr 21, 2017
2 parents 3a259cf + c53c751 commit ce6307a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ Unreleased
the top-level ``<li>`` tag has the id now.
See https://github.com/Pylons/pyramid_debugtoolbar/pull/285

- Emit a warning and disable the toolbar if the app is being served by
a forking / multiprocess wsgi server that sets
``environ['wsgi.multiprocess']`` to ``True``. This should help avoid
confusing issues in certain deployments like gunicorn and uwsgi multiprocess
modes. See https://github.com/Pylons/pyramid_debugtoolbar/pull/286

3.0.5 (2016-11-1)
-----------------

Expand Down
9 changes: 9 additions & 0 deletions pyramid_debugtoolbar/toolbar.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import os
import warnings

from pyramid.exceptions import URLDecodeError
from pyramid.httpexceptions import WSGIHTTPException
Expand Down Expand Up @@ -186,6 +187,14 @@ def toolbar_tween(request):
):
return handler(request)

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)

root_path = debug_toolbar_url(request, '', _app_url='')
if p.startswith(root_path):
# we know root_path will always have a trailing slash
Expand Down

0 comments on commit ce6307a

Please sign in to comment.