From 661d7e2a7387dedf7717a7669eb6cbb00011cf04 Mon Sep 17 00:00:00 2001 From: "T.Rzepka" Date: Sun, 28 Jul 2024 20:46:51 +0200 Subject: [PATCH] Since Python 3.13 threading.Thread has an internal _handle attribute which is overwritten by watchdog creating an exception. --- src/watchdog/observers/read_directory_changes.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/watchdog/observers/read_directory_changes.py b/src/watchdog/observers/read_directory_changes.py index 81b835c5..16daaa63 100644 --- a/src/watchdog/observers/read_directory_changes.py +++ b/src/watchdog/observers/read_directory_changes.py @@ -47,13 +47,13 @@ class WindowsApiEmitter(EventEmitter): def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT, event_filter=None): super().__init__(event_queue, watch, timeout, event_filter) self._lock = threading.Lock() - self._handle = None + self._dir_handle = None def on_thread_start(self): 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) + self._dir_handle = get_directory_handle(watch_path) if platform.python_implementation() == "PyPy": @@ -65,11 +65,11 @@ def start(self): sleep(0.01) def on_thread_stop(self): - if self._handle: - close_directory_handle(self._handle) + if self._dir_handle: + close_directory_handle(self._dir_handle) def _read_events(self): - return read_events(self._handle, self.watch.path, self.watch.is_recursive) + return read_events(self._dir_handle, self.watch.path, self.watch.is_recursive) def queue_events(self, timeout): winapi_events = self._read_events()