On what CPU cores are my Python processes running?

前端 未结 3 1054
臣服心动
臣服心动 2020-12-14 14:36

The setup

I have written a pretty complex piece of software in Python (on a Windows PC). My software starts basically two Python interpreter shells.

3条回答
  •  不思量自难忘°
    2020-12-14 15:15

    Since you are using the threading module which is build up on thread. As the documentation suggests, it uses the ''POSIX thread implementation'' pthread of your OS.

    1. The threads are managed by the OS instead of Python interpreter. So the answer will depend on the pthread library in your system. However, CPython uses GIL to prevent multiple threads from executing Python bytecodes simutanously. So they will be sequentialized. But still they can be separated to different cores, which depends on your pthread libs.
    2. Simplly use a debugger and attach it to your python.exe. For example the GDB thread command.
    3. Similar to question 1, the new process is managed by your OS and probably running on a different core. Use debugger or any process monitor to see it. For more details, go to the CreatProcess() documentation page.

提交回复
热议问题