-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Project reloads every time sqlite
is touched
#11
Comments
Check my pr #10 |
I have a similar issue which is quite annoying: @q0w can I use your PR code to filter watched folders? To say something like "don't watch mediafiles". |
Yes, you can. Use bultin PythonFilter or write your own. Check watchfiles docs, its simple to ignore specific folders
|
Thanks a lot, it works as expected: # https://watchfiles.helpmanual.io/api/filters/#custom-filters
class MediaFilesFilter(DefaultFilter):
"""Prevent a local server reload when uploading files"""
def __call__(self, change: Change, path: str) -> bool:
return super().__call__(change, path) and "mediafiles" not in path In settings: WATCHFILES = {
"watch_filter": "django_watchfiles.custom_filters.MediaFilesFilter",
"raise_interrupt": False,
"debug": False,
} Just waiting for the PR to be accepted and merged, sothat I can use the package itself rather than writing my own internal app. |
this project is nice cause it works (as opposed to watchman) but it's a bit too raw. if django-watchfiles is the interface to watchfiles i think it needs to expose at least some basic level of control in a bit more user friendly way. the bare minimum being disabling debug messages and having a whitelist/blacklist. thank you for looking into this. |
This is an alpha quality project still. When I have time I’ll work on it again. |
thank you for doing all the heavy lifting and research. for now i removed this dependency from our projects and simply add a from pathlib import Path
import watchfiles
from django.conf import settings
from django.utils import autoreload
class WatchfilesReloader(autoreload.BaseReloader):
def tick(self):
watcher = watchfiles.watch(*settings.WATCHFILES, debug=False)
for file_changes in watcher:
for _change, path in file_changes:
self.notify_file_changed(Path(path))
yield
def replaced_get_reloader() -> autoreload.BaseReloader:
return WatchfilesReloader()
autoreload.get_reloader = replaced_get_reloader |
I think dc1af91 fixed this by filtering changes coming from watchfiles. |
This issue is pretty similar to: #2
I'm re-opening/duplicating the original issue with some additional context as I think some filtering is not properly taking effect here. I'm seeing the server restart/reload when anything in sqlite is touched (something which doesn't happen with the default
StatReloader
)Is this behaviour known + intended/expected? (If not I'm happy to investigate a bit further)
I guess I could easily move sqlite out of my project and into a separate dir (where it won't trigger reloads)
Below is a comparison between the default/watchfiles reloaders
Screencast.from.24-09-22.10.21.08.mov
e.g. when I login to the admin panel:
The text was updated successfully, but these errors were encountered: