I am running a python script from another python script and I am wondering how I can catch exceptions from the parent python script.
My parent python script calls another python script n amount of times. Eventually that called script will exit with a 'ValueError' exception. I'm wondering if there is a way for my parent python script to notice this and then stop executing.
Here is the base code as-is:
import os
os.system('python other_script.py')
I have tried things such as this to no avail:
import os
try:
os.system('python other_script.py')
except ValueError:
print("Caught ValueError!")
exit()
and
import os
try:
os.system('python other_script.py')
except:
print("Caught Generic Exception!")
exit()