-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix watchdog reload worker repeatedly if there are multiple changed files #1555
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1555 +/- ##
==========================================
+ Coverage 92.17% 94.21% +2.04%
==========================================
Files 23 22 -1
Lines 2312 2315 +3
Branches 424 426 +2
==========================================
+ Hits 2131 2181 +50
+ Misses 141 84 -57
- Partials 40 50 +10
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
Why not break out of the loop when need_reload
is True
, instead of continuing to look at every file?
In my case, when I update a dependency package there are about 30 files being touched at the same time which trigger the app to reload 30 times continuously (breaking the loop there will only update the mtime of a single file). This patch allow all modified files' mtime to be updated before trigger reload. It should have no big performance impact since it have to scan all files in the ordinary case when no file is modified. |
I guess... it does seem like it would potentially have a negative impact though. Especially for larger projects. I am hesitant to accept a change like this that could potentially have a large impact on a number of developers in their daily workflow. I understand your issue and concern, but I would rather find a solution that does not also impact the existing operation. |
Instead, what if we make
|
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. |
I might have a better look at the auto-reloader in the coming days; its killing of existing processes seems rather broken, and this patch is probably a step in the right direction. |
This needs a few changes. First of all, multiprocessing.Process is used to run subprocess ... meaning a chain of two processes. After fixing that so that subprocess is used directly, it can also be terminated reliably, and we no longer need those hacks to kill all child processes. I worked on this in the Trio branch, but in principle the changes should apply to asyncio implementation too. It appears to be working with single as well as multiple workers, as long as the master server kills its worker processes when it receives SIGTERM (dunno how Windows-compatible that is, might need another solution there). My current revision: @lexhung could you give it a little bit of polish and testing on current Sanic master? |
Hi @Tronic We may want to go through manual review for this to get merged. I implemented the tests however it is quite tricky to get the patch coverage passed. These are parts that related to OS exceptions and it is not clear to me how to set that up without making the tests brittle. |
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. |
@ahopkins Are you reviewing this? |
Yes. I am taking a look at it. I will respond with more detailed thoughts when I am back at my workstation (beginning of the week) and can fire up a few tests on this. |
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. |
Looks like this is still stuck with no review. Even if the patch isn't quite the ideal solution we might have in our minds, I believe that it is definitely an improvement and it works on my machine, so I suggest for this to be merged as well. |
I am thinking this should be closed once #1827 is finished. Am I mistaken? |
When there are multiple changed files (e.g. git pull, installing new version of a package, etc.), watchdog attempts to reload workers at first detected change and repeat for every changed file.
The patch allow gathering all changes into a single restart action.