Skip to content
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

question: why schedule observer per-directory? #45

Open
crockeo opened this issue Oct 15, 2024 · 0 comments
Open

question: why schedule observer per-directory? #45

crockeo opened this issue Oct 15, 2024 · 0 comments

Comments

@crockeo
Copy link

crockeo commented Oct 15, 2024

Hi! This isn't an issue request so much as a discussion, but I had a question about the implementation that I wanted to ask about.

In jurigged.live::Watcher::on_prepare we end up self.observer.schedule-ing once per-directory:

def on_prepare(self, module_name, filename):
JuriggedHandler(self, filename).schedule(self.observer)
self.registry.log(WatchOperation(filename))
->
def schedule(self, observer):
# Watch the directory, because when watching a file, the watcher stops when
# it is deleted and will not pick back up if the file is recreated. This happens
# when some editors save.
observer.schedule(self, os.path.dirname(self.filename))

This can run into OS-level limits on the number of file watchers available, which causes jurigged to fail on large projects. I've been messing around with this on such a project, and found a workaround by monkeypatching Watcher instead use a single watchdog.Observer.

I was wondering: is this a bad idea for a reason I don't understand yet? And if not: any chance y'all would accept a pull request to make this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant