subprocess - Execute another python script, then shut down current script -


i have python script script_a.py uses subprocess.call() executes script script_b.py it's last instruction before ending. need script_b.py wait until script_a.py closes before proceeding own instructions. using while loop within script_b.py. how can this? of current solutions have tried have script_a.py waiting until script_b.py finished before closes itself. have feeling might involve atexit() or similar, lost.

many thanks!

you make totally hacky crap

script_b.py

while not os.path.exists("a.done"):pass time.sleep(0.2) # little longer sure ... os.remove("a.done") ... # rest of script b 

script_a.py

import atexit atexit.register(lambda *a:open("a.done","w")) 

or instead of popen do

os.execl("/usr/bin/python","script_b.py") 

Comments