Hacker News new | ask | show | jobs
by glic3rinu 2191 days ago
When I add autoreload functionality to my programs I just spawn a thread that checks for last modified date and then re-executes the program with os.execlp(sys.argv[0], *sys.argv)

I found my solution superior in several ways:

- I can force an autoreload just by saving a file (no file changes needed to force an md5 diff)

- exec() doesn't suffer from the side effects of not restarting the python interpreter, clean start every time :)

- it is also quite portable and doesn't require extra dependencies like inotify/fswatch/etc. </ul>