Reputation: 63
I have FOLDER1 FOLDER2 FOLDER3. All of those contain a PYTHON_CODE.py, all of the folders are located in the same place. How can I run all three PYTHON_CODE.py from all of the three folder?
Is it possible to make them all run at the same time, and NOT in the way that first FOLDER1's PYTHON_CODE.py finishes, then comes the second one and third (Again, NOT this way).
Upvotes: 0
Views: 482
Reputation: 29
I would go for a higher level script located in the main folder that calls your others scripts to run them in parallel.
You can use the os
module (in particular the os.system
function) to define a function which runs the script passed as argument.
Then, exploiting the multiprocessing
module, you can spawn processes to be run in parallel by means of the Pool
object.
The Pool.map
function distributes the works among the defined processes, in a parallel manner.
Here you can find a good example for you case.
References:
Upvotes: 1