title: Raspberry Pi - is it possible to restart a python program, if an error occures and interrupts the running code?
body: <p>I was wondering if it was possible to restart a python program (automatically ofc, preferably with an easy script) it case it encounters a problem and closes it. My algorithm sometimes doesn't function the way I want it to, but it doesn't really matter if I am able to get it to restart.</p>
  
  <p>Code: </p>
  
  <pre><code>dongle = serial.Serial(port='/dev/ttyUSB0',baudrate=9600,timeout=0,rtscts=0,xonxoff=0)
  ard = serial.Serial(port="/dev/ttyACM0", baudrate=9600)
  time.sleep(0.5)
  while True:
  #       ard.open()
          discard = ard.readline()
          string = ard.readline()
          print discard
          print string
          time.sleep(0.5)
          temperature, truebung, latitude, longtitude  = string.split(",")
  </code></pre>
  
  <p>Basically, what's happening once every 10 times, is that "string" is corrupt. It does not give me the data I want it to. It misses something or gives me a random value. Normally, the string should look something like this "24.04,0.23,18.92442,40.25255" but it sometimes is corrupt and looks like this "40.25255" or ".25255". I "ard.readline" twice because originally, the "discard" was always corrupt, now the string is also corrupt. What can I do to fix that? It doesn't matter if string isn't correct once every 10 times but it crashes my program and that's the thing I want it not to do. </p>