d
This commit is contained in:
parent
a576cea8e8
commit
c53baccb38
26
app.py
26
app.py
@ -33,6 +33,9 @@ printer_model = "QL-1100"
|
||||
backend = 'pyusb'
|
||||
printer = 'usb://0x04f9:0x20a7'
|
||||
|
||||
# Create a lock to manage printer access
|
||||
printer_lock = threading.Lock()
|
||||
|
||||
# Convert PDF to image
|
||||
def convert_pdf_to_image(pdf_path):
|
||||
"""Converts a PDF to a PIL Image"""
|
||||
@ -76,17 +79,22 @@ def print_address_label(pdf_path):
|
||||
cut=True
|
||||
)
|
||||
|
||||
app.logger.info("Sending to printer...")
|
||||
send(
|
||||
instructions=instructions,
|
||||
printer_identifier=printer,
|
||||
backend_identifier=backend,
|
||||
blocking=True
|
||||
)
|
||||
app.logger.info("Print job sent successfully")
|
||||
app.logger.info("Waiting to acquire printer lock...")
|
||||
with printer_lock: # Ensure only one thread sends a job at a time
|
||||
app.logger.info("Sending to printer...")
|
||||
try:
|
||||
send(
|
||||
instructions=instructions,
|
||||
printer_identifier=printer,
|
||||
backend_identifier=backend,
|
||||
blocking=True
|
||||
)
|
||||
app.logger.info("Print job sent successfully")
|
||||
except Exception as e:
|
||||
app.logger.error(f"Error during printing: {str(e)}")
|
||||
|
||||
except Exception as e:
|
||||
app.logger.error(f"Error during printing: {str(e)}")
|
||||
app.logger.error(f"Error during label printing: {str(e)}")
|
||||
|
||||
# Worker thread that processes files from the queue
|
||||
def process_queue():
|
||||
|
Loading…
x
Reference in New Issue
Block a user