Handle pstats exceptions on the profiler display

This commit is contained in:
mvantellingen
2011-02-13 21:21:25 +01:00
parent 382c9b17fb
commit 52ee7dcef9

View File

@@ -9,7 +9,6 @@ import pstats
from flask import current_app
from flaskext.debugtoolbar.panels import DebugPanel
from flaskext.debugtoolbar.utils import format_fname
@@ -35,15 +34,17 @@ class ProfilerDebugPanel(DebugPanel):
if self.is_active:
return functools.partial(self.profiler.runcall, view_func)
def process_response(self, request, response):
if not self.is_active:
return False
if self.profiler is not None:
self.profiler.disable()
stats = pstats.Stats(self.profiler)
try:
stats = pstats.Stats(self.profiler)
except TypeError:
self.is_active = False
return False
function_calls = []
for func in stats.sort_stats(1).fcn_list:
current = {}
@@ -112,3 +113,4 @@ class ProfilerDebugPanel(DebugPanel):
return self.render('panels/profiler.html', context)