class FileModifiedHandler(FileSystemEventHandler):

    def __init__(self, path, file_name, callback):
        self.file_name = file_name
self.callback = callback
self.observer = Observer()
self.observer.schedule(self, path, recursive=False)
self.observer.start()
self.observer.join()

def on_modified(self, event):
    if not event.is_directory and event.src_path.endswith(self.file_name):
        self.observer.stop()
self.callback()
How do I watch a file, not a directory for changes using Python?