Watchdog (osx) does not notify about remote network changes

I use Watchdog to track a network directory, non-recursive, for a specific template of files that will be created over time. The problem I see is that although it works fantastically when I test locally if I make changes to the controlled directory from a remote machine, events do not fire.

Here are the specific details of my configuration:

  • OSX
  • monitoring a single directory, non-recursive, on an NFS mount
  • python 2.6

An example of my problem can be easily reproduced using a fragment of a stock example:

import sys import time import logging from watchdog.observers import Observer from watchdog.events import LoggingEventHandler if __name__ == "__main__": logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S') event_handler = LoggingEventHandler() observer = Observer() observer.schedule(event_handler, path=sys.argv[1], recursive=False) observer.start() try: while True: time.sleep(1) except KeyboardInterrupt: observer.stop() observer.join() 

If you run this in a network directory and then make changes from the same system, events will be sent. But if you then make changes to the directory from another computer on the network, no events are sent.

Did I miss something regarding kqueue restrictions (or maybe FSEvents on OSX, since it talks about Watchdog preference first)?

I was set up for this python package and was about to start using it for other scripts to replace file system polling, but I can not find any information on why I am seeing this problem.

Update

I also tested MacFSEvents and got the same issue. Then I modified the above test script to force different observers to try:

 # does not work with remote changes from watchdog.observers.fsevents import FSEventsObserver as Observer # does not work with remote changes from watchdog.observers.kqueue import KqueueObserver as Observer # only option that works because its actually polling every second from watchdog.observers.polling import PollingObserver as Observer 

So, at least for now, I can use the survey observer and not change the code until someone can shed light on the real problem that I am facing.

+7
source share
1 answer

I am sure that file system events do not work on NFS - the reason is that, as a rule, the kernel manages file system events, because it has a layer in the kernel that starts activity - with NFS there is no way for notifying you of changes, you can only get a list of inodes, write several blocks, read some blocks, etc. This is pretty minimal.

In order for file system events to work on NFS, you had to constantly query the NFS server.

For AFP, there may be some tool that, if you have juice, you can just install netatalk and try that.

If you absolutely need to do something like this, but netatalk does not, it is best to run OSXFuse and write the NFS label, which actually just sits there and polls for changes. But you will be limited to "truncated, modified, added, deleted", etc.

See also: Use libfuse in a project, without root access (for installation)? FTP servers and inotify / kqueue / FSEvents

+6
source

All Articles