Reputation: 111
I want to start a Python program and then have that program start another Python program and have them both run at the same time. To clarify, I want program A to contain lines of code that will open up another python program, B, and run program B. I then want A and B to run at the same time until they both finish.
I have tried using execfile()
method but that stops program A, waits until program B finishes, and then lets program A finish. I want both A and B to run at the same time.
Also, the programs do not need to communicate between each other. No information is shared between them, they simply run independently of each other at the same time.
I understand that I can just open two instances of IDLE and run each one separately but I would really like to just start Program A and have it automatically start program B and both run at the same time.
Upvotes: 1
Views: 45
Reputation: 49920
Assuming you're using Python3.8, concurrent.futures
"provides a high-level interface for asynchronously executing callables." (Details here: https://docs.python.org/3/library/concurrent.futures.html#module-concurrent.futures) So your callable could call execfile
and have it run concurrently.
Upvotes: 1