multi-thread QCoreApplication stops before cProfile, PySide6

32 Views Asked by At
def main(argv)->int:
    print("standalone")

    app = QCoreApplication(argv)

    init(app)
    wally.worker_thread.finished.connect(app.quit)
    
    return app.exec()


if __name__ == "__main__":
    profile = config.get_def_value(CONFIG.profile)
    
    retval = -1
    print("profiling")
    prof = cProfile.Profile()
    retval = prof.runcall(main, sys.argv)
    prof.dump_stats("pywally.prof")

    print("\nPROFILE:\n")
    prof.strip_dirs()
    prof.sort_stats('cumtime').print_stats(10)
    prof.sort_stats('ncalls').print_stats(10)
    print("\nEND OF PROGRAM:\n")
    sys.exit(retval)

What I tried to do here is to run PySide6's QCoreApplication, let it finish within cProfile, and then get the cProfile data. The program ends on app.exit() tho, so the output ends at "standalone", nothing later is ever reached. I bet the line wally.worker_thread.finished.connect(app.quit) is the culprit, but I need it to exit gracefully...

0

There are 0 best solutions below