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__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
printer_busy = False
|
||||||
|
|
||||||
# Set up logging
|
# Set up logging
|
||||||
log_file = 'log.txt'
|
log_file = 'log.txt'
|
||||||
|
|
||||||
@ -116,10 +118,13 @@ def save_images(images, pdf_path):
|
|||||||
|
|
||||||
# Worker thread that processes files from the queue
|
# Worker thread that processes files from the queue
|
||||||
def file_worker():
|
def file_worker():
|
||||||
|
global printer_busy
|
||||||
while True:
|
while True:
|
||||||
file_path = file_queue.get()
|
file_path = file_queue.get()
|
||||||
if file_path is None: # Shutdown signal
|
if file_path is None: # Shutdown signal
|
||||||
break
|
break
|
||||||
|
while printer_busy:
|
||||||
|
time.sleep(1)
|
||||||
app.logger.info(f"Processing file: {file_path}")
|
app.logger.info(f"Processing file: {file_path}")
|
||||||
images = convert_pdf_to_images(file_path)
|
images = convert_pdf_to_images(file_path)
|
||||||
if images:
|
if images:
|
||||||
@ -130,11 +135,16 @@ def file_worker():
|
|||||||
|
|
||||||
# Printer worker
|
# Printer worker
|
||||||
def printer_worker():
|
def printer_worker():
|
||||||
|
global printer_busy
|
||||||
while True:
|
while True:
|
||||||
image, path = image_queue.get()
|
image, path = image_queue.get()
|
||||||
if image is None:
|
if image is None:
|
||||||
|
if printer_busy:
|
||||||
|
time.sleep(10)
|
||||||
|
printer_busy = False
|
||||||
break
|
break
|
||||||
with lock:
|
with lock:
|
||||||
|
printer_busy = True
|
||||||
print_address_label(image, path)
|
print_address_label(image, path)
|
||||||
image_queue.task_done()
|
image_queue.task_done()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user