diff --git a/app.py b/app.py index c2c87ae..a96b6f3 100644 --- a/app.py +++ b/app.py @@ -14,6 +14,8 @@ import time app = Flask(__name__) +printer_busy = False + # Set up logging log_file = 'log.txt' @@ -116,10 +118,13 @@ def save_images(images, pdf_path): # Worker thread that processes files from the queue def file_worker(): + global printer_busy while True: file_path = file_queue.get() if file_path is None: # Shutdown signal break + while printer_busy: + time.sleep(1) app.logger.info(f"Processing file: {file_path}") images = convert_pdf_to_images(file_path) if images: @@ -130,11 +135,16 @@ def file_worker(): # Printer worker def printer_worker(): + global printer_busy while True: image, path = image_queue.get() if image is None: + if printer_busy: + time.sleep(10) + printer_busy = False break with lock: + printer_busy = True print_address_label(image, path) image_queue.task_done()