Auto restarting python application

This is a cool sample on how to write an automatic self-restarting python application after a timeout, of course you can modify this application to be much more sophisticated so it can close all open files before restarting or restarting based on a signal (SIGHUP maybe?) or whatever you like

#!/usr/bin/env python

import os, sys, time

def main():  
    print "AutoRes is starting"
    executable = sys.executable
    args = sys.argv[:]
    args.insert(0, sys.executable)

    print "Respawning"
    os.execvp(executable, args)

if __name__ == "__main__":  
comments powered by Disqus