From 52ee7dcef9b1aab7e3463c241917d17fb684bebd Mon Sep 17 00:00:00 2001 From: mvantellingen Date: Sun, 13 Feb 2011 21:21:25 +0100 Subject: [PATCH] Handle pstats exceptions on the profiler display --- flaskext/debugtoolbar/panels/profiler.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/flaskext/debugtoolbar/panels/profiler.py b/flaskext/debugtoolbar/panels/profiler.py index 0f51b49..6c831c5 100644 --- a/flaskext/debugtoolbar/panels/profiler.py +++ b/flaskext/debugtoolbar/panels/profiler.py @@ -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) +