首页 > 系统相关 >Python多进程代码调试工具

Python多进程代码调试工具

时间:2023-03-23 23:02:09浏览次数:44  
标签:Python 代码 stdin self Pdb sys pdb 调试

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()

标签:Python,代码,stdin,self,Pdb,sys,pdb,调试
From: https://www.cnblogs.com/marsggbo/p/17249835.html

相关文章