I'm using Watchdog to monitor a network directory, non-recursive, for a specific pattern of files to be created over time. The issue I am seeing is that while it works fantastic when I test locally, if I make changes to the monitored directory from a remote machine, the events are not triggered.
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 by using the stock example snippet:
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 start this on a network directory, and then make changes from the same system, the events are dispatched. But if you then make changes to the directory from another machine on the network, no events are dispatched.
Am I missing something regarding limitations of kqueue (or could be FSEvents on OSX, since it says its preferred first by Watchdog)?
I was stoked on this python package, and was going to start using it for other scripts to replace filesystem polling, but I can't seem to find any information regarding why I am seeing this issue.
Update
I also tested MacFSEvents and got the same problem. Then I modified the above test script to forcibly try different observers:
# 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 polling observer and not have to modify my code, until someone can shed some light on the real problem I am having.