Skip to content

Commit

Permalink
do not add requests to the history until they are fully processed
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerickel committed Jan 27, 2024
1 parent 0c816b9 commit 6398b09
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 3 additions & 4 deletions demo/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def make_app():
settings['mako.directories'] = __name__ + ':templates'
settings['mako.module_directory'] = __name__ + ':mako_modules'
settings['debugtoolbar.reload_templates'] = True
settings['debugtoolbar.hosts'] = ['127.0.0.1']
settings['debugtoolbar.hosts'] = ['::1', '127.0.0.1']
settings['debugtoolbar.intercept_redirects'] = True
settings['debugtoolbar.exclude_prefixes'] = ['/static', '/favicon.ico']

Expand Down Expand Up @@ -139,6 +139,5 @@ def make_app():
app = make_app()

if __name__ == '__main__':
from wsgiref.simple_server import make_server
httpd = make_server('', 8080, app)
httpd.serve_forever()
from waitress import serve
serve(app, listen='localhost:8080')
1 change: 1 addition & 0 deletions demo/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'pyramid_chameleon',
'selenium',
'SQLAlchemy',
'waitress',
]

setup(name='debugtoolbar_demo',
Expand Down
6 changes: 5 additions & 1 deletion src/pyramid_debugtoolbar/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ def toolbar_tween(request):
request, panel_classes, global_panel_classes, default_active_panels
)
request.debug_toolbar = toolbar
request_history.put(request.pdtb_id, toolbar)

_handler = handler
for panel in toolbar.panels:
Expand Down Expand Up @@ -350,6 +349,11 @@ def toolbar_tween(request):
return response

finally:
# do not add the request until it is complete, some panels
# do not properly support rendering while the request is still
# processing
request_history.put(request.pdtb_id, toolbar)

# break circref
del request.debug_toolbar

Expand Down

0 comments on commit 6398b09

Please sign in to comment.