Skip to content

No file system events observed when not using recursive mode #918

Open
@cedrickring

Description

@cedrickring

We tried to listen for events on a single file, without the need for watching recursively. However without specifying recursive=True, no events were observed.

Platform: macOS 12.6 & Ubuntu 18.04
Python: 3.9.14

Code to reproduce:

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')
    path = sys.argv[1] if len(sys.argv) > 1 else '.'
    event_handler = LoggingEventHandler()
    observer = Observer()
    observer.schedule(event_handler, path)
    observer.start()
    try:
        while True:
            time.sleep(1)
    finally:
        observer.stop()
        observer.join()

and launching with: python file.py <path to single file>.

Also using the FSEventsObserver on macOS didn't change the outcome. Only specifying recursive=True did.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions