This commit is contained in:
zman 2025-04-07 17:29:54 -04:00
parent 2561febca9
commit 935344d581

8
app.py
View File

@ -80,18 +80,18 @@ def print_address_label(pdf_path):
cut=True cut=True
) )
# Try to acquire the printer lock with a timeout # Try to acquire the printer lock with a longer timeout
max_retries = 3 max_retries = 3
retry_delay = 2 # seconds retry_delay = 10 # 10 seconds retry delay
for attempt in range(max_retries): for attempt in range(max_retries):
if printer_lock.acquire(timeout=5): # 5 seconds timeout if printer_lock.acquire(timeout=30): # 30 seconds timeout to allow more time for the printer
try: try:
app.logger.info(f"Attempting to send print job (Attempt {attempt + 1})...") app.logger.info(f"Attempting to send print job (Attempt {attempt + 1})...")
send( send(
instructions=instructions, instructions=instructions,
printer_identifier=printer, printer_identifier=printer,
backend_identifier=backend, backend_identifier=backend,
blocking=True blocking=True # Ensure blocking, so we wait for the print to complete
) )
app.logger.info("Print job sent successfully") app.logger.info("Print job sent successfully")
break break