A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: inotify read timeout not in ms (#5876)
grembo76064178f566
diff --git a/src/documents/management/commands/document_consumer.py b/src/documents/management/commands/document_consumer.pyindex 919530544..97f9fcc59 100644--- a/src/documents/management/commands/document_consumer.py+++ b/src/documents/management/commands/document_consumer.py@@ -286,10 +286,10 @@ class Command(BaseCommand):def handle_inotify(self, directory, recursive, is_testing: bool):logger.info(f"Using inotify to watch directory for changes: {directory}")- timeout = None+ timeout_ms = Noneif is_testing:- timeout = self.testing_timeout_ms- logger.debug(f"Configuring timeout to {timeout}ms")+ timeout_ms = self.testing_timeout_ms+ logger.debug(f"Configuring timeout to {timeout_ms}ms")inotify = INotify()inotify_flags = flags.CLOSE_WRITE | flags.MOVED_TO | flags.MODIFY@@ -298,7 +298,8 @@ class Command(BaseCommand):else:descriptor = inotify.add_watch(directory, inotify_flags)- inotify_debounce: Final[float] = settings.CONSUMER_INOTIFY_DELAY+ inotify_debounce_secs: Final[float] = settings.CONSUMER_INOTIFY_DELAY+ inotify_debounce_ms: Final[int] = inotify_debounce_secs * 1000finished = False@@ -306,7 +307,7 @@ class Command(BaseCommand):while not finished:try:- for event in inotify.read(timeout=timeout):+ for event in inotify.read(timeout=timeout_ms):path = inotify.get_path(event.wd) if recursive else directoryfilepath = os.path.join(path, event.name)if flags.MODIFY in flags.from_mask(event.mask):@@ -323,7 +324,7 @@ class Command(BaseCommand):# Current time - last time over the configured timeoutwaited_long_enough = (monotonic() - last_event_time- ) > inotify_debounce+ ) > inotify_debounce_secs# Also make sure the file exists still, some scanners might write a# temporary file first@@ -342,11 +343,11 @@ class Command(BaseCommand):# If files are waiting, need to exit read() to check them# Otherwise, go back to infinite sleep time, but only if not testingif len(notified_files) > 0:- timeout = inotify_debounce+ timeout_ms = inotify_debounce_mselif is_testing:- timeout = self.testing_timeout_ms+ timeout_ms = self.testing_timeout_mselse:- timeout = None+ timeout_ms = Noneif self.stop_flag.is_set():logger.debug("Finishing because event is set")