def run(self): import cProfile profiler = cProfile.Profile() profiler.enable() threading.Thread.run(self) profiler.disable() profiler.dump_stats(self.filename)