linux - Python script doesn't restart itself properly -


i have python script , want have restart itself. found following lines googling around:

def restart_program():     """restarts current program.     note: function not return. cleanup action (like     saving data) must done before calling function."""     python = sys.executable     os.execl(python, python, * sys.argv) 

but problems became apparent right after trying out. i'm running on small embedded system , ran out of memory quick (after 2 or 3 iterations of function). checking process list, can see whole bunch of python processes. now, realize, check process list , kill processes have pid myself - have or there better python solution?

this spawns new child process using same invocation used spawn first process, not stop existing process (more precisely: existing process waits child exit).

the easier way refactor program don't have restart it. why need this?


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -