From 8a8c4d226fab756ad0c3ba923ec71d0555757491 Mon Sep 17 00:00:00 2001 From: "T.Rzepka" Date: Wed, 24 Jul 2024 23:26:26 +0200 Subject: [PATCH] Fix silently fails if path is file #1034 (Windows only) issue by testing if it's a file. --- src/watchdog/observers/read_directory_changes.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/watchdog/observers/read_directory_changes.py b/src/watchdog/observers/read_directory_changes.py index fe038cc2..b3d8691b 100644 --- a/src/watchdog/observers/read_directory_changes.py +++ b/src/watchdog/observers/read_directory_changes.py @@ -55,7 +55,10 @@ def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT, event_fi self._handle = None def on_thread_start(self): - self._handle = get_directory_handle(self.watch.path) + watch_path = self.watch.path + if os.path.isfile(watch_path): + watch_path = os.path.dirname(watch_path) + self._handle = get_directory_handle(watch_path) if platform.python_implementation() == "PyPy":