Created
May 1, 2011 20:42
-
-
Save EntityReborn/950857 to your computer and use it in GitHub Desktop.
bootstrap for a restartable python process.
This file contains hidden or 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
# The only requirements are that the process ends with a specific return code (7 in this case) | |
import os | |
import sys | |
import subprocess | |
class main(object): | |
def __init__(self, file, cwd): | |
self.file = os.path.abspath(file) | |
self.cwd = os.path.abspath(cwd) | |
def run(self): | |
restart = True | |
while restart: | |
run = subprocess.Popen([sys.executable, self.file], cwd=self.cwd) | |
retn = run.wait() | |
if retn != 7: | |
restart = False | |
m = main("botmain.py", ".") | |
m.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment