Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider supporting HOT reload with hmr? #5667

Closed
CNSeniorious000 opened this issue Jan 10, 2025 · 3 comments
Closed

Consider supporting HOT reload with hmr? #5667

CNSeniorious000 opened this issue Jan 10, 2025 · 3 comments

Comments

@CNSeniorious000
Copy link

CNSeniorious000 commented Jan 10, 2025

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 in flask run --reload but reloads only when needed in hmr 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.

@ThiefMaster
Copy link
Member

IMHO this adds a huge risk of weird bugs. People can add something like this themselves in their app if they want that.

@ThiefMaster ThiefMaster closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2025
@CNSeniorious000
Copy link
Author

I really understand that this may never become a default behavior, and I can see your concern regarding potential risks that could arise.
However, I feel it would be a bit of a pity to close this issue so quickly. Would it be possible to move it to a discussion instead? I'd love to explore whether there might be others in the community who are interested in trying it out and contributing ideas.

Thanks again for considering! 😊

@ThiefMaster
Copy link
Member

Closed issues don't prevent discussions, it's not locked :)

@pallets pallets locked and limited conversation to collaborators Jan 10, 2025
@ThiefMaster ThiefMaster converted this issue into discussion #5668 Jan 10, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants