Run python every 2 seconds

I know how to start a function every x seconds or minute. The main problem is that it happens that my script stops for « no reason » or that windows crashs. Ram was ok at that time. I can’t let this …