diff --git a/silk/collector.py b/silk/collector.py index ee3d1c13..7f4b3f74 100644 --- a/silk/collector.py +++ b/silk/collector.py @@ -133,11 +133,11 @@ def _record_meta_profiling(self): self.request.save() def stop_python_profiler(self): - if hasattr(self.local, 'pythonprofiler'): + if getattr(self.local, 'pythonprofiler', None): self.local.pythonprofiler.disable() def finalise(self): - if hasattr(self.local, 'pythonprofiler'): + if getattr(self.local, 'pythonprofiler', None): s = StringIO() ps = pstats.Stats(self.local.pythonprofiler, stream=s).sort_stats('cumulative') ps.print_stats()