如何在 Python PDB 中显示 thread/process Id?

How do I display thread/process Id in Python PDB?

在 Python 中,有没有办法在使用 PDB 调试时显示 thread/process ID?

我正在查看 https://docs.python.org/2/library/pdb.html 但找不到与之相关的任何内容?

(pdb) import os,threading; os.getpid(), threading.current_thread().ident

如果您需要经常这样做,在您的 .pdbrc 文件中添加一个别名会很方便:

alias tid import os,threading;; p os.getpid(), threading.current_thread().ident