Comment 10 for bug 322887

Revision history for this message
Marc Tardif (cr3) wrote :

Another approach attempted was to log stack frames to file from a separate thread. For example, the following code repeatedly writes the frames every 10 seconds. However, when Zope3 blocks, this thread also seems to stop.

def runforever(name):
    import threadframe, traceback, time, sys
    file = open(name, "w")
    while True:
        file.write(">>>>>%s, number of threads = %d\n" % (time.strftime("%H:%M:%S"), len(threadframe.dict())))
        time.sleep(10)
        for id, frame in threadframe.dict().iteritems():
            file.write("===== [%d] %s" % (id, sys.getrefcount(frame)))
            traceback.print_stack(frame, file=file)
            file.write("\n")
            file.flush()

import thread
thread.start_new_thread(runforever, ("/tmp/thread1.log",))