如何在python中获取子进程模块的进程ID和CPU核心

问题描述

我正在编写将使用子进程及其方法check_output的python代码,我也在通过线程调用以利用多核优势(假设通过线程调用子进程使用多核)

现在我要打印的是子进程输出,进程ID,cpu内核用于在OS中执行睡眠命令 示例:

  result = subprocess.check_output(["sleep","5"])
  print(result)
  print("Process ID: ",os.getpid()) # This is wrong i guess,because in OS subprocess used different process ID and cpu,If this is wrong,How to get PID of subprocess
  print("cpu Core used: ") # This also required help to print
  

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)