sanic icon indicating copy to clipboard operation
sanic copied to clipboard

auto_reload support for Windows

Open mungojam opened this issue 5 years ago • 6 comments

This would be really useful for us. We don't have an option to use Linux for development unfortunately

mungojam avatar Oct 05 '18 10:10 mungojam

Today our reloader is completely dependant in the way POSIX works ... But I really think that a more generic approach is possible to make this behavior available for POSIX and Windows almost transparently, but I'll have to do some hard digging in there to see if my idea really works ...

vltr avatar Oct 05 '18 14:10 vltr

I took a quick look was surprised to find that the re-loader is only really dependent on posix for killing the existing server process and children and not to detect file changes. My guess is we could probably use something like psutil to make this more uniformly platform independent but not sure we'd want that as a dependency.

abuckenheimer avatar Oct 09 '18 03:10 abuckenheimer

This functionality could actually be put into a plugin. And current implementation is also a little bit error-prone. It'll certainly require more mature process management.

yunstanford avatar Oct 09 '18 03:10 yunstanford

@abuckenheimer @yunstanford I know I have made some tools in the past that were way more complex because they required either binary or byte-compiled code to be hot-replaced, either in Windows or Linux or (whatever the name of that embed machine made in hell). This should not be complicated, with my first idea being wrapping the server stuff and launching a second process with multiprocessing.spawn, that would certainly work on Linux and Windows. The main process would watch for file changes and restart (kill+spawn) the new server on some events (either by using inotify in Linux or simple polling in Windows, though I think there might be something better / already done for that).

Also, I agree with the idea that this should be put into a plugin and not within Sanic since it is just a tool, not a production specific feature.

Please, let's continue this discussion on the community forums if possible :wink:

vltr avatar Oct 09 '18 14:10 vltr

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is incorrect, please respond with an update. Thank you for your contributions.

stale[bot] avatar May 14 '19 23:05 stale[bot]

@​stale nope

andreymal avatar May 14 '19 23:05 andreymal