]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Corrects the timeout's interaction with files waiting to be consumed 1421/head
authorTrenton Holmes <holmes.trenton@gmail.com>
Wed, 10 Aug 2022 01:20:47 +0000 (18:20 -0700)
committerTrenton Holmes <holmes.trenton@gmail.com>
Mon, 15 Aug 2022 00:47:59 +0000 (17:47 -0700)
src/documents/management/commands/document_consumer.py
src/documents/tests/test_management_consumer.py

index 1b232c072939e6b2610d82269cb93459e5c680a1..3a3b8a163b2214d488d50e7ecd5b6fde82784dfc 100644 (file)
@@ -248,7 +248,7 @@ class Command(BaseCommand):
 
         while not finished:
             try:
-                for event in inotify.read(timeout):
+                for event in inotify.read(timeout=timeout):
                     if recursive:
                         path = inotify.get_path(event.wd)
                     else:
@@ -281,6 +281,15 @@ class Command(BaseCommand):
                 # These files are still waiting to hit the timeout
                 notified_files = still_waiting
 
+                # If files are waiting, need to exit read() to check them
+                # Otherwise, go back to infinite sleep time, but only if not testing
+                if len(notified_files) > 0:
+                    timeout = inotify_debounce
+                elif is_testing:
+                    timeout = self.testing_timeout_ms
+                else:
+                    timeout = None
+
                 if self.stop_flag.is_set():
                     logger.debug("Finishing because event is set")
                     finished = True
index 71cc97be17b315e40b4bd3d7220a1d4aa057c81f..be8f26d12c69d9c4977cc91fecbdfd773df9f1b2 100644 (file)
@@ -2,7 +2,6 @@ import filecmp
 import os
 import shutil
 from threading import Thread
-from time import monotonic
 from time import sleep
 from unittest import mock