funcserver.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:funcserver 作者: deep-compute 项目源码 文件源码
def dump_stacks(self):
        '''
        Dumps the stack of all threads. This function
        is meant for debugging. Useful when a deadlock happens.

        borrowed from: http://blog.ziade.org/2012/05/25/zmq-and-gevent-debugging-nightmares/
        '''

        dump = []

        # threads
        threads = dict([(th.ident, th.name)
                            for th in threading.enumerate()])

        for thread, frame in sys._current_frames().items():
            if thread not in threads: continue
            dump.append('Thread 0x%x (%s)\n' % (thread, threads[thread]))
            dump.append(''.join(traceback.format_stack(frame)))
            dump.append('\n')

        return ''.join(dump)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号