From 00d737714b90df57ccf28d9264e14855c454a0e5 Mon Sep 17 00:00:00 2001 From: zman Date: Mon, 7 Apr 2025 17:54:54 -0400 Subject: [PATCH] asdfasd --- app.py | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/app.py b/app.py index 6f342ba..b864937 100644 --- a/app.py +++ b/app.py @@ -11,7 +11,6 @@ import mimetypes import logging from logging.handlers import RotatingFileHandler import time -import fcntl # For file locking app = Flask(__name__) @@ -85,24 +84,15 @@ def print_address_label(pdf_path): cut=True ) - app.logger.info("Attempting to acquire printer lock...") - - # Open the printer device and lock it to prevent concurrent access - with open(printer, 'wb') as printer_device: - fcntl.flock(printer_device, fcntl.LOCK_EX) # Exclusive lock on printer device - try: - app.logger.info("Sending to printer...") - send( - instructions=instructions, - printer_identifier=printer, - backend_identifier=backend, - blocking=True - ) - app.logger.info("Print job sent successfully") - finally: - # Ensure the lock is released after the print job is finished - fcntl.flock(printer_device, fcntl.LOCK_UN) - + app.logger.info("Sending to printer...") + 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)}") @@ -116,7 +106,6 @@ def process_queue(): # Process the file (convert and print) app.logger.info(f"Processing file: {file_path}") print_address_label(file_path) - time.sleep(10) # Signal that the task is done file_queue.task_done() @@ -154,4 +143,4 @@ def upload_file(): return jsonify({'message': f'File {file.filename} uploaded and queued for processing'}), 200 if __name__ == '__main__': - app.run(debug=True) + app.run(debug=True) \ No newline at end of file