vibora icon indicating copy to clipboard operation
vibora copied to clipboard

[RFC] Add dependency-free auto reloader

Open lwakefield opened this issue 7 years ago • 5 comments

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?

lwakefield avatar Jun 26 '18 18:06 lwakefield

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 avatar Jun 26 '18 18:06 NyanKiyoshi

@NyanKiyoshi I would suggest that this implementation, and resulting api is simpler.

lwakefield avatar Jun 26 '18 19:06 lwakefield

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 avatar Jul 12 '18 06:07 danieldaeschle

@danieldaeschle that makes sense. Could you link to the other PR, maybe I can work on handling those edge cases in this PR?

lwakefield avatar Jul 12 '18 12:07 lwakefield

You already linked it. #61

danieldaeschle avatar Jul 12 '18 13:07 danieldaeschle