I use a Python script on a raspberry that communicates with the Internet and USB with an Arduino and it happens that one of the 2 communications blow because of some error, and I would like in case this file python stops because of an error that the Raspberry restarts ! can some one hepl me ?
Advertisement
Answer
This is a solution to restart the Pi. You will have to check for your error first. That can be done using a try/except construction:
import os try: <<your code here>> except: os.system("sudo reboot") # reboots the pi