Hem Hem - 1 year ago 110
Python Question

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

In Python, is there a way to display thread/process ID while debugging using PDB?

I was looking at https://docs.python.org/2/library/pdb.html but could not find anything related to it?

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

If you need to do this often, it would be convenient to add an alias in your .pdbrc file:

alias tid import os,threading;; p os.getpid(), threading.current_thread().ident
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download