def dump_stacktrace(self, signum, frame): stackdumps = self._thread_stacks() enginestatus = format_engine_status(self.crawler.engine) liverefs = format_live_refs() msg = "Dumping stack trace and engine status" \ "\n{0}\n{1}\n{2}".format(enginestatus, liverefs, stackdumps) log.msg(msg)
def test_format_live_refs(self): o1 = Foo() # NOQA o2 = Bar() # NOQA o3 = Foo() # NOQA self.assertEqual( trackref.format_live_refs(), '''\ Live References Bar 1 oldest: 0s ago Foo 2 oldest: 0s ago ''') self.assertEqual( trackref.format_live_refs(ignore=Foo), '''\ Live References Bar 1 oldest: 0s ago ''')
def dump_stacktrace(self, signum, frame): log_args = { 'stackdumps': self._thread_stacks(), 'enginestatus': format_engine_status(self.crawler.engine), 'liverefs': format_live_refs(), } logger.info("Dumping stack trace and engine status\n" "%(enginestatus)s\n%(liverefs)s\n%(stackdumps)s", log_args, extra={'crawler': self.crawler})
def create_report(self, figures): s = "" s += "SCRAPY MEMORY DEBUGGER RESULTS\n\n" for f in figures: s += "%-30s : %d %s\n" % f if settings.getbool('TRACK_REFS'): s += os.linesep s += format_live_refs() return s