- Podcasts
- alexkras.com
- How to Restart Python Script after Exception and Run it Forever
How to Restart Python Script after Exception and Run it Forever
alexkras.com
- February 23, 2018
About this episode
Here is a simple trick that I used to restart my python script after unhandled exception. Let’s say I have this simple script called test.py that I want to run forever. It will just wait 2 seconds and throw an error. I use the following script called forever in the same directory: It uses python to open as a new subprocess. It does so in an infinite while loop…