def request(ctx, flow): global step, ssl print("==========") print(f"GC: {gc.collect()}") print(f"Threads: {threading.active_count()}") step += 1 if step == 1: all_objects = muppy.get_objects() ssl = muppy.filter(all_objects, SSL.Connection)[0] if step == 2: ib = refbrowser.InteractiveBrowser(ssl, 2, str_fun, repeat=False) del ssl # do this to unpollute view ib.main(True)
def test(self): tr = tracker.SummaryTracker() testDir = os.path.dirname(os.path.abspath(sys.modules[__name__].__file__)) testFileSmall = testDir + "/solvency/2.0/random/spv_20_instance.xbrl" logFile = testDir + "/tmp/test.log" dumpFilePrefix = testDir + "/tmp/dump_" prevNumObjects = 0 for idx in range(3): # increase this range for testing print("\nIteration " + str(idx)) arelleRunArgs = ['--keepOpen', '--logFile', 'logToStdErr', '--logfile', logFile, '--file', testFileSmall] cntlr = parseAndRun(arelleRunArgs) cntlr.modelManager.close() cntlr.close() del cntlr gc.collect() all_objects = muppy.get_objects() numObjects = len(all_objects) diffObjects = numObjects - prevNumObjects prevNumObjects = numObjects print(str(numObjects) + " (" + str(diffObjects) + " more)") browserRoot = None if False: # <<<--- set this to get object dump file with open(dumpFilePrefix + str(idx) + ".txt", "w") as text_file: idx = 0 for o in all_objects: if browserRoot is None and isinstance(o, arelle.ModelValue.QName): browserRoot = o idx += 1 otype = "" try: otype = str(type(o)) except: pass try: print("type=" + otype + " " + str(o), file=text_file) except: pass if False: ibrowser = refbrowser.InteractiveBrowser(browserRoot) ibrowser.main() all_objects= None gc.collect() tr.print_diff() if idx > 1: assert diffObjects < 50, "Check for new objects leak"
def getDebugInfo(self, itemname): """Give debug info about a particular item.""" global profile outf = StringIO() if itemname == "": outf.write("the item was empty") if profile: all_objects = muppy.get_objects() sum1 = summary.summarize(all_objects) summary.print_(sum1, 100) ib = refbrowser.InteractiveBrowser(self) ib.main() return outf.getvalue() itemname = keywords.fixID(itemname) itemlist = vtype.parseItemList(itemname) item = self.getSubValue(itemlist) item.writeDebug(outf) return outf.getvalue()
def _on_keyboard_down(self, keyboard, keycode, text, modifiers): if keycode[1] == 'escape': base.stopTouchApp() elif keycode[1] == 'd': self.set_mode('insert') elif keycode[1] == 's': self.set_mode('select') elif keycode[1] == 'w': self.set_item('atom') elif keycode[1] == 'e': self.set_item('ellipse') elif keycode[1] == 'r': self.set_item('rectangle') elif keycode[1] == 'p': self.active_graph.show_tree(0) elif keycode[1] == 'o': self.view_symbolic_formula() elif keycode[1] == 'n': self.show_gringo_query() elif keycode[1] == 'g': self.show_save() elif keycode[1] == 'l': self.show_load() elif keycode[1] == 'y': print self.name_manager.get_all() print asp.Line.get_all_lines() elif keycode[1] == 't': self.toggle_sidepanel() elif keycode[1] == 'tab': if not self.show_sidepanel: self.toggle_sidepanel() self.ids.atom_input.focus = True elif keycode[1] == '.': if DEBUG: rb = refbrowser.InteractiveBrowser(self) rb.main() # self.all_objects = muppy.get_objects() # sum1 = summary.summarize(self.all_objects) # summary.print_(sum1) # self.tracker.create_snapshot() # self.tracker.stats.print_summary() return True