I have a Python 3.6 script which is multi-threaded and runs on a windows 10 machine with 12 cores.
I want to run multiple instances of the script but I am worried about Pythons GIL issue in terms of the performance of each instance of the script.
Would doing any of the below work around this as I am under the impression that when I run an instance of the script, the Python process it runs within is running on just one CPU core and each thread called from within the script 'time slices' on that one core...
Therefore would:
A: Starting each instance of the script in its own CMD window allow the OS to automatically deal with starting each scripts parent Python processes on its own core and prevent any locking taking place...
or
B: Starting each CMD session via a shortcut that sets its affinity to a specific core and then run the Python script so that the python process and its threads run on the specific core the CMD process has been set to use...
or
C: My understanding of how threading and the Python GIL works is not correct and I need understand...
Any help will be much appreciated.
threadinguses real system threads and as such, your threaded code is not necessarily restricted to just one CPU - the underlying OS's thread scheduler can, and sometimes will spread them over different CPUs. However, no two threads may run at the same time due to the dreaded GIL so parallel execution is out of question. If you run multiple instances of your script, however, they will be running in different Python interpreter instances, therefore each will have its own GIL so multiple instances may run in parallel.