Skip to content

Commit 8cfa70e

Browse files
committed
Convert the ProfilingPanels check for the profiler into a function.
The func variable is a tuple, so each element needs to be checked for the profiler.
1 parent abeebe0 commit 8cfa70e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

debug_toolbar/panels/profiling.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import absolute_import, division, unicode_literals
22

3+
from django.utils import six
34
from django.utils.translation import ugettext_lazy as _
45
from django.utils.safestring import mark_safe
56
from debug_toolbar.panels import Panel
@@ -16,13 +17,23 @@
1617
INVALID_PROFILER_FUNC = '_lsprof.Profiler'
1718

1819

20+
def contains_profiler(func_tuple):
21+
"""Helper function that checks to see if the tuple contains
22+
the INVALID_PROFILE_FUNC in any string value of the tuple."""
23+
has_profiler = False
24+
for value in func_tuple:
25+
if isinstance(value, six.string_types):
26+
has_profiler |= INVALID_PROFILER_FUNC in value
27+
return has_profiler
28+
29+
1930
class DjangoDebugToolbarStats(Stats):
2031
__root = None
2132

2233
def get_root_func(self):
2334
if self.__root is None:
2435
for func, (cc, nc, tt, ct, callers) in self.stats.items():
25-
if len(callers) == 0 and INVALID_PROFILER_FUNC not in func:
36+
if len(callers) == 0 and not contains_profiler(func):
2637
self.__root = func
2738
break
2839
return self.__root

0 commit comments

Comments
 (0)