Live data from Hacker News

Reloadr – Hot code reloading tool for Python

github.com

11–20 of 58 posts

Re: Reloadr – Hot code reloading tool for Python

#12
post #9

Having a hot reloaded set up for both my django (It's built in) environment and Web app environment is such a force multiplier. It's not about simply saving time doing it manually. It fundamentally changes my dev-test/experiment workflow. I love being able to tab to a server file, make a change, tab to a client file, make another change, and instantly test it in a browser.

Have you tried PHP? :) I jest, but really I feel like we've made things so complicated it just gets in our way. Our Javascript pipeline is huge, complicated, and requires you to sit down and wrap your head around it every time you want to modify it. If I get to greenfield another project, it's going to be so bloody simple.

I'm writing applications for people to manage fleets of thousands of robots in real-time from the other side of the planet. There's no room for "bloody simple" =D

They don't resemble traditional websites/CRUD apps a whole lot. Much closer to Sim City + Factorio.

When it comes to making your standard issue website/webapp, I think some of them could stand to be simpler.

Re: Reloadr – Hot code reloading tool for Python

#14
I'm slightly confused by this wording in the docs: "This allows it to reload code that is followed by blocking instructions such as the infinite loops you can find in the examples."

The examples just have loops where the reloaded function is called in a loop. Is this just updating the definition of the function between calls?

Re: Reloadr – Hot code reloading tool for Python

#15
Few years back, I did something similar to this with PHP.

I was always marveled at the capacities of xDebug, and never stopped using it since I found it (Some 10+ years), and honestly, coupling it with PHPStorm is another level.

But still, hitting reload on the browser, or running a script from the CLI gets tiring after the 20th time; so I made this little class where you would call a method, and the method will reload the script where the code was located continuously until I managed to get it to do what I wanted.

It was very Johnny Mnemonic, but it worked.

Re: Reloadr – Hot code reloading tool for Python

#16
Ha, I'm just working on integrating the `pydev.debugger` code reloading into `debugpy` (so that the code reloading from the PyDev debugger will be available for Python-VSCode debugger users too).

The in-memory reloading (which may be seen at: https://github.com/fabioz/PyDev.Debugger/blob/main/_pydevd_b...) unfortunately doesn't work all the time (fixing the references at runtime in Python is difficult), but it works well enough for the cases where you have a simple function and change it (that file does explain some of the issues that the reloading faces).

One major issue is that after doing the reload, you need to get out of the function and then back into it to see the difference -- so, if you're stopped in the function in a breakpoint, it's not possible to simply drop the function and restart it as Python itself doesn't support that... maybe that's a good idea for a PEP ;)

Anyways, when it works, it's pretty nice in that you don't have to restart your whole debug session to see changes (the other approach, which webservers use in general is just restart the whole process, so, for instance, Django has an initial process just monitoring for changes and a 2nd process which is actually serving requests which is restarted when something changes -- not as good if you have a heavy startup or are working with something where you have to click through multiple things to get to the state which you want).

Post reply on HN