Consider supporting HOT reload with hmr
?
#5668
Replies: 3 comments
-
IMHO this adds a huge risk of weird bugs. People can add something like this themselves in their app if they want that. |
Beta Was this translation helpful? Give feedback.
-
I really understand that this may never become a default behavior, and I can see your concern regarding potential risks that could arise. Thanks again for considering! 😊 |
Beta Was this translation helpful? Give feedback.
-
Closed issues don't prevent discussions, it's not locked :) |
Beta Was this translation helpful? Give feedback.
-
Hot Module Replacement has been existed in JavaScript ecosystem for a long time, but Python web applications are still using full reloads by default.
To solve this situation, I implemented the
hmr
package, which does the fine-grained dependency tracking, on-demand reloading jobs. Here is a demo of what the results look like:flask.mov
Obviously the
a.py
runs everytime inflask run --reload
but reloads only when needed inhmr app.py
. But everything else works fine (at least for this small demo)You may say that user should use lazy imports and cache expensive calculations themselves, but in fact not every function can be cached, and lazy imports may lead to ugly code style. This can be solved with on-demand hot reloading without overhead. So I believe this is the future.
Although this is just a minimal demo, but I value hmr's potential in the Python ecosystem, and believe that with our efforts this is a reachable goal.
Tip
You can try the example above here with
hmr app.py
About
hmr
, you can refer to its README for details.Beta Was this translation helpful? Give feedback.
All reactions