Python script stopping after a while

view story

http://stackoverflow.com – I have a raspberry pi with raspbian on it, and I've created a python script that I need to have running all the time. The problem is that after running for an hour or so, the script suddenly stops, and the python process shuts down. I have no idea why, and I'm very new to linux so I don't know how to debug it or anything. I don't think it's a memory issue because during the while loop I free and reinit all objects used. How can I find out what the issue is, or at least automatically restart the program once it stops? This is the code: import time import sys import ftputil import pygame impo (HowTos)