I have a following question. I have a script my_script.py. I would like to run it again, until it ends without errors. I run my_script.py from master.py like this:
import my_script
if __name__ == '__main__':
my_script.main()
I tried:
if __name__ == '__main__':
while True:
try:
my_script.main()
except:
pass
but this never ends. How can I end master.py when my_script.py ends succesfully ?
>Solution :
You can just set a flag or break to see if you finished or not, e.g.:
if __name__ == '__main__':
while True:
try:
my_script.main()
break
except:
pass