How to get the process ID of python programm?

Question:

Is there a way to get the process ID (PID) of a python program?

The program was started from the command line.

Asked By: asdewkas

||

Answers:

this should do it:

import os
pid = os.getpid()
print(pid)
Answered By: Helmut
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.