def finish(self, *args, **kw): super().finish(*args, **kw) if self.get_argument("profile", None) and os.environ.get("ALLOW_PROFILING"): self.collector.stop() formatter = PlopFormatter(max_stacks=9001) if self.collector.samples_taken: formatter.store(self.collector, "{0}_{1}.profile".format(self.__class__.__name__, time.time()))