vibora
vibora copied to clipboard
[RFC] Add dependency-free auto reloader
This PR introduces a run_with_reloader function on the Vibora class. This method will watch all loaded modules for file changes, and reload the server when there is a file change.
Below is an example:
import time
from vibora import Vibora, Response
app = Vibora()
@app.route('/', cache=False)
async def home():
return Response(str(time.time()).encode())
if __name__ == '__main__':
# app.run(debug=False, port=8000)
app.run_with_reloader(debug=False, port=8000)
reload.py copies from Werkzeug reloader to avoid adding external dependencies. It does not include watchdog, not support for python 2.
TODO:
- [ ] Add LICENSE from werkzeug
- [ ] Add tests
- [ ] Add documentation
- [ ] Update README
WDYT? Is this approach something that could work? If so, are there more considerations that need to be made?
I realize that in https://github.com/vibora-io/vibora/pull/61 @frnkvieira mentioned working on another implementation, but maybe this can save time for other features?
Why not enabling by default the auto-reloader when debugging is enabled on Vibora.run?
And allow to force-disable the auto-reloader through the keyword reload (False).
Just like how it's done in most framework. That would be cleaner.
@NyanKiyoshi I would suggest that this implementation, and resulting api is simpler.
Frank says in the other PR that Vibora has a few corner cases to handle in auto-reloading thanks to the "necromancer". I don't think that he want to merge this.
@danieldaeschle that makes sense. Could you link to the other PR, maybe I can work on handling those edge cases in this PR?
You already linked it. #61