Open mconigliaro opened 2 months ago
According to the code, self.dump_filename
doesn't get set unless DEBUG_TB_PROFILER_ENABLED
is True
. But if I enable that, I get this:
Traceback (most recent call last):
File "/Users/mike/Developer/other/test/test-flask/.venv/lib/python3.12/site-packages/flask/app.py", line 1498, in __call__
return self.wsgi_app(environ, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mike/Developer/other/test/test-flask/.venv/lib/python3.12/site-packages/flask/app.py", line 1476, in wsgi_app
response = self.handle_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mike/Developer/other/test/test-flask/.venv/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mike/Developer/other/test/test-flask/.venv/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mike/Developer/other/test/test-flask/.venv/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mike/Developer/other/test/test-flask/.venv/lib/python3.12/site-packages/flask_debugtoolbar/__init__.py", line 149, in dispatch_request
return view_func(**req.view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/cProfile.py", line 109, in runcall
self.enable()
ValueError: Another profiling tool is already active
Set environment variant to resolve the issues like "no attribute 'dump_filename' ". DEBUG_TB_PROFILER_ENABLED = True DEBUG_TB_DUMP_FILENAME_FORMAT = {request.url} # other setting like: {request.method}, {request.path}
It seems that ProfilerDebugPanel().dump_filename
attribute is undefined whenDEBUG_TB_PROFILER_ENABLED != True
.
Possible solution is to modify __init__(self, jinja_env, context={})
method, someting like:
diff --git a/.venv/Lib/site-packages/flask_debugtoolbar/panels/profiler.py b/.venv/Lib/site-packages/flask_debugtoolbar/panels/profiler.py
--- a/.venv/Lib/site-packages/flask_debugtoolbar/panels/profiler.py
+++ b/.venv/Lib/site-packages/flask_debugtoolbar/panels/profiler.py (date 1727604243564)
@@ -27,6 +27,8 @@
self.dump_filename = current_app.config.get(
"DEBUG_TB_PROFILER_DUMP_FILENAME"
)
+ else:
+ self.dump_filename = None
def has_content(self):
return bool(self.profiler)
Feel free to submit a PR with your suggested fix.
I enable the profiler and this happens:
I have to clear my cookies to make the error go away.
Environment: