Skip to content

Commit 661d7e2

Browse files
committed
Since Python 3.13 threading.Thread has an internal _handle attribute which is overwritten by watchdog creating an exception.
1 parent 4ffce94 commit 661d7e2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/watchdog/observers/read_directory_changes.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ class WindowsApiEmitter(EventEmitter):
4747
def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT, event_filter=None):
4848
super().__init__(event_queue, watch, timeout, event_filter)
4949
self._lock = threading.Lock()
50-
self._handle = None
50+
self._dir_handle = None
5151

5252
def on_thread_start(self):
5353
watch_path = self.watch.path
5454
if os.path.isfile(watch_path):
5555
watch_path = os.path.dirname(watch_path)
56-
self._handle = get_directory_handle(watch_path)
56+
self._dir_handle = get_directory_handle(watch_path)
5757

5858
if platform.python_implementation() == "PyPy":
5959

@@ -65,11 +65,11 @@ def start(self):
6565
sleep(0.01)
6666

6767
def on_thread_stop(self):
68-
if self._handle:
69-
close_directory_handle(self._handle)
68+
if self._dir_handle:
69+
close_directory_handle(self._dir_handle)
7070

7171
def _read_events(self):
72-
return read_events(self._handle, self.watch.path, self.watch.is_recursive)
72+
return read_events(self._dir_handle, self.watch.path, self.watch.is_recursive)
7373

7474
def queue_events(self, timeout):
7575
winapi_events = self._read_events()

0 commit comments

Comments
 (0)