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.