asdf
This commit is contained in:
parent
64209694e3
commit
0ad49d7962
10
app.py
10
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()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user