Watchdog not detecting file directory changes if processes from more than one machineis creating file in a shared network directory

Asked by : melany wijngaard 2020-09-10 04:00

I am trying to detect a file in a shared network directory using WatchDog 2.1.6 and Python 3.7.3 The o/s is Linux RHEL. Two machines m1 and m2 have processes that create files in /shared/data/.

If the Watchdog script is running only on m1, it detects changes to the directory in the share - but only if the files are created by processes from machine m1.

If processes from machine m2 creates files in the share, WatchDog does not detect the change.

I would like only one Watchdog based process on just machine m1 to detect files created by processes on /shared/data from any other machine.

The code I am using is below. Any suggestions appreciated.

 import time
from watchdog.observers.polling import PollingObserver
from import FileSystemEventHandler

class OnMyWatch:
    # Set the directory on watch
    watchDirectory = "/shared/data"

    def __init__(self): = PollingObserver()

    def run(self):
        event_handler = Handler(), self.watchDirectory, recursive = True)
            while True:
            print("Observer Stopped")

class Handler(FileSystemEventHandler):

     def on_any_event(event):
         print(f"Event received.{event.event_type}, {event.src_path}")

if __name__ == '__main__':
    watch = OnMyWatch()

0 Answers

0 votes
Related Posts
Related Posts
Given corners of a quadrilateral, Plot s...
enora aubert enora aubert
2020-01-11  7:05am 2020-01-11 7:05am
Error in the Random Forest model fit wit...
laly da silva laly da silva
2021-10-20  4:45am 2021-10-20 4:45am
how use SCTP_nodelay in python?...
benjamin beck benjamin beck
2021-04-09  7:33am 2021-04-09 7:33am
Creating a new column with value depende...
liam walters liam walters
2021-11-03  2:54pm 2021-11-03 2:54pm
Pandas dataframe custom columns and rows...
morgan riviere morgan riviere
2021-04-16  8:53pm 2021-04-16 8:53pm