]> git.donarmstrong.com Git - scanner_workflow.git/commitdiff
sleep in a loop if the filesize is increasing
authorDon Armstrong <don@donarmstrong.com>
Sat, 25 Feb 2023 22:06:43 +0000 (14:06 -0800)
committerDon Armstrong <don@donarmstrong.com>
Sat, 25 Feb 2023 22:06:43 +0000 (14:06 -0800)
scanner_workflow.py

index 64514f20e56a392c067e0a1764aff1c358323a87..453f087afa9a44f9be2478b7f2eb45afbf1d1853 100755 (executable)
@@ -107,8 +107,16 @@ class ScannerWorkflow:
             if check.returncode == 0:
                 pdf_good = True
                 break
-            # sleep for 10 seconds if the PDF was bad
-            sleep(10)
+            file_size = pdf_file.stat().st_size
+            # sleep in a loop for 10 seconds if the file size is still
+            # increasing
+            while True:
+                sleep(10)
+                new_size = pdf_file.stat().st_size
+                if new_size > file_size:
+                    file_size = new_size
+                else:
+                    break
         if not pdf_good:
             error(f"PDF was not good, skipping {orig_pdf} for now")
             return