I am trying to write a flask application with several routes that uses python-escpos functions to print a receipt.
The route works and prints the receipt instantly but subsequent prints are either delayed by 2+ minutes or if the flask application is killed the backlog prints instantly.
I was initially using python-escpos 2.2.0 which worked flawlessly with prints occurring instantly one after another each time I accessed the route. Python-escpos 2.2.0 (stable release) however does not allow for text manipulation or printing images. I switched over to the latest pre-release 3.0a4 and this is where my problems began with the delay.
from flask import Flask, flash
from escpos import *
import PIL
app = Flask(__name__, template_folder='.')
@app.route('/')
def homepage():
printerip = "192.168.3.197"
Epson = printer.Network(printerip)
Epson.text('CHARGING')
Epson.cut()
return 'printed'
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True, port=80)
The expectation is that when visiting the route the receipt will print instantly even if a few seconds delay, currently experiencing print delays of 2+ minutes.