ASDFASDFAS

This commit is contained in:
zman 2025-04-07 17:50:44 -04:00
parent fe07e61505
commit a60cfae01c

17
app.py
View File

@ -48,7 +48,7 @@ def convert_pdf_to_image(pdf_path):
return None
# Function to print address labels
def print_address_label(pdf_path):
def print_address_label(pdf_path, print_complete_event):
try:
# Convert PDF to image
image = convert_pdf_to_image(pdf_path)
@ -95,6 +95,10 @@ def print_address_label(pdf_path):
except Exception as e:
app.logger.error(f"Error during printing: {str(e)}")
finally:
# Signal that the current print job is done
print_complete_event.set()
# Worker thread that processes files from the queue
def process_queue():
@ -103,10 +107,17 @@ def process_queue():
file_path = file_queue.get()
if file_path is None: # Shutdown signal
break
# Create an event to signal print job completion
print_complete_event = threading.Event()
# Process the file (convert and print)
app.logger.info(f"Processing file: {file_path}")
print_address_label(file_path)
time.sleep(10)
print_address_label(file_path, print_complete_event)
# Wait until the current print job is completed before processing the next one
print_complete_event.wait()
# Signal that the task is done
file_queue.task_done()