0

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).

1
  • You can try the multiprocessing library. Commented May 24, 2021 at 9:04

1 Answer 1

1

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:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.