Created
June 16, 2017 19:42
-
-
Save hoseinit/a694d784a5c38ea1b0e832a8d4947cd9 to your computer and use it in GitHub Desktop.
Rerun python script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import time | |
while True: | |
print("Launching process..") | |
p = subprocess.Popen("python3 script.py", shell=True) | |
p.wait() | |
print("Process crashed. Restarting in 2 seconds..") | |
time.sleep(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will run "script.py" in an infinite loop, if it crashes it waits 2 seconds and restarts it!