From e71612224ef438219f4124a4e903d0943bc162a4 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Tue, 14 Mar 2023 03:05:49 -0400 Subject: [PATCH] return from InotifyEmitter.queue_events() if not launched when thread is inactive (#963) * return from InotifyEmitter.queue_events() if not launched when thread is inactive * add logging * Update inotify.py --- src/watchdog/observers/inotify.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/watchdog/observers/inotify.py b/src/watchdog/observers/inotify.py index c128bfbaa..03946e2df 100644 --- a/src/watchdog/observers/inotify.py +++ b/src/watchdog/observers/inotify.py @@ -64,6 +64,7 @@ """ +import logging import os import threading from .inotify_buffer import InotifyBuffer @@ -91,6 +92,9 @@ ) +logger = logging.getLogger(__name__) + + class InotifyEmitter(EventEmitter): """ inotify(7)-based event emitter. @@ -124,6 +128,9 @@ def on_thread_stop(self): def queue_events(self, timeout, full_events=False): # If "full_events" is true, then the method will report unmatched move events as separate events # This behavior is by default only called by a InotifyFullEmitter + if self._inotify is None: + logger.error("InotifyEmitter.queue_events() called when the thread is inactive") + return with self._lock: event = self._inotify.read_event() if event is None: