getting ProcessId within Python code

后端 未结 4 1024
渐次进展
渐次进展 2021-01-01 16:19

I am in Windows and Suppose I have a main python code that calls python interpreter in command line to execute another python script ,say test.py .

So test.py is exe

4条回答
  •  失恋的感觉
    2021-01-01 17:13

    You will receive the process ID of the newly created process when you create it. At least, you will if you used fork() (Unix), posix_spawn(), CreateProcess() (Win32) or probably any other reasonable mechanism to create it.

    If you invoke the "python" binary, the python PID will be the PID of this binary that you invoke. It's not going to create another subprocess for itself (Unless your python code does that).

提交回复
热议问题