News for hackers. Stuff that matters.
Re:Hot-swapping Python 3 code by glic3rinu on Sunday June 14, 2020 @11:00AM (#23518124)
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>

There are no comments on this comment yet.