Comment on Show HN: Change Python code while it's running using a reloading loopComments−_carl_jung6yThis is awesome. A nice improvement would be to have the loop continue with the old code when there are errors (rather than pausing iteration).−rcfox6yThat seems like it would be confusing. Imagine trying to track down the source of behaviour that no longer exists in your code...−ianai6yHow would that be possible without having to essentially keep track of two files? Nice idea though.−earenndil6yBasically, 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
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