Open Evidlo opened 5 years ago
This is still a problem. I wanted to use httpwatcher on RaspberryPI and since the files are stored on sdcard and any edit and save of the file with vim takes some time (vim probably first removes the original file and then renames the working copy of the file .swp), the httpwatcher will error with 404.
Sounds like a good feature to add. Does any one of you want to create a PR, or should I take this upon myself? @blackdaemon @Evidlo
@jobveldhuis Go ahead. I actually implemented this to a degree a while ago, but the files are gone now.
@Evidlo Please check the latest version of the dev branch and see whether or not this is the use case you had in mind. You are now able to use: --interval <number>
to increase or decrease the maximum polling of the server.
@jobveldhuis The behavior I'm proposing is just subtly different from a simple reload interval. I came up with a contrived example to show how httpwatcher can actually miss file change events if implemented this way:
Current behavior (with --interval 1
):
0.00s file changed <- reload
0.25s file changed
0.50s file changed
0.75s file changed
1.00s file changed <- reload
1.25s file changed
1.50s file changed
As you can see, the last two file change events are not picked up by httpwatcher. If we instead wait for a period of no activity before reloading, we can catch these events:
Proposed behavior (with --interval 1
):
0.00s file changed
0.25s file changed
0.50s file changed
0.75s file changed
1.00s file changed
1.25s file changed
1.50s file changed
1.75s
2.00s
2.25s
2.50s <- reload
So basically, a file change event should start/reset a timer which then triggers the page reload.
I think this would be implemented with tornado's call_later function with a callback to trigger the page reload.
So you are proposing a delay of some kind? Sounds good, I will look into this tonight!
I'm using httpwatcher to automatically reload my browser while authoring content with a static website generator. Unfortunately, the website generator does a full rebuild of the website when changes are detected, which can cause httpwatcher to trigger a reload before the generator is finished rebuilding or even trigger httpwatcher multiple times in one rebuild.
This could be solved pretty simply if httpwatcher had a
--timeout N
option whereby anN
millisecond countdown is started when a change is detected before httpwatcher starts to reload the page.Is this equivalent to
watcher_inverval
? In any case, it's not yet available as a flag.