Skip to content

Comment on Show HN: Change Python code while it's running using a reloading loop

Comments

This is awesome. A nice improvement would be to have the loop continue with the old code when there are errors (rather than pausing iteration).

That seems like it would be confusing. Imagine trying to track down the source of behaviour that no longer exists in your code...

How would that be possible without having to essentially keep track of two files? Nice idea though.

Basically, you just need a double buffer system:

- Always run from the back buffer

- Always scan the updated file into the front buffer

- If the front buffer is fresh AND the front buffer contains no bugs, bufferswap

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.