title: how to restart a python program after it crashes
body: <p>I have a python script that starts a program and automates through it, continuously processing new data and saves to a pre-set directory.<br />
  What is the recommended way to run the Python script forever, logging errors when they occur, and restarting when it crashes?<br />
  so far I've came across the <code>os.execv</code> and have this to start:</p>
  <pre><code>import sys
  import os
   
  def pyexcept(t, v, tb):
     import traceback
  ## restarts the script
  os.execv( sys.executable, '')
  </code></pre>
  <p>but I often get stuck trying to figure out the next step, could someone explain the next steps i could take, ty!</p>