Skip to content

question: why schedule observer per-directory? #45

@crockeo

Description

@crockeo

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions