It's a very limited-use small story, but I'll try to synchronize without using multithreading, which I'm not sure about. Maybe it doesn't help most people. Also, there must be a better way. But this is enough. (At this point) I'm new to Python w
Actually, I wanted to do something like the following.
This could use subprocess. I used popen () because I don't want to wait until the end.
import subprocess
p1 = subprocess.popen("command_A")
p2 = subprocess.popen("command_B")
To wait for both to finish. .. .. There was a wait ().
r1 = p1.wait()
r2 = p2.wait()
You can also check the return value properly.
If there is no problem, execute the last external process. You don't have to synchronize this time, so check_call () etc. is OK.
p3 = subprocess.check_call("command_C")
Study more and write better code! (LOL)
Recommended Posts