0
点赞
收藏
分享

微信扫一扫

Python多进程代码调试工具

德州spark 2023-03-26 阅读 66

https://github.com/Lightning-AI/forked-pdb

import sys
import pdb

class ForkedPdb(pdb.Pdb):
    """
    PDB Subclass for debugging multi-processed code
    Suggested in: https://stackoverflow.com/questions/4716533/how-to-attach-debugger-to-a-python-subproccess
    """
    def interaction(self, *args, **kwargs):
        _stdin = sys.stdin
        try:
            sys.stdin = open('/dev/stdin')
            pdb.Pdb.interaction(self, *args, **kwargs)
        finally:
            sys.stdin = _stdin

用法: ForkedPdb().set_trace()



举报

相关推荐

0 条评论