FAIRYFAR-INTERNAL
 
  FAIRYFAR-INTERNAL  |  SITEMAP  |  ABOUT-ME  |  HOME  
使用pdb-attach调试Python程序

pdb-attach可以调试运行中的python进程,尤其是后台进程。

安装

使用

需要先修改py文件:

snippet.python
import pdb_attach
pdb_attach.listen(50000)  # 选择一个未使用的端口号
 
def do_stuff():
    ...
 
if __name__ == '__main__:
    do_stuff()

attach:

snippet.python
$ python -m pdb_attach <PID> 50000
(Pdb)

之后的就是使用pdb调试程序了。

调试结束需要detach:

snippet.python
(Pdb) detach

参考



打赏作者以资鼓励:
移动端扫码阅读:
目录: