Sprtch / victoria

🖨️ Printer daemon interface for Zebra printer
GNU General Public License v3.0
0 stars 0 forks source link

Capture exit signal and clear the Printer table #7

Closed tperale closed 3 years ago

tperale commented 3 years ago

Clearing the printer table allow huron to know which printer is available on the "printer" page.

tperale commented 3 years ago

On signal exit the database entry for each printer are set as "unavailable".

def signal_handler(signal, frame):
    PrinterTable.query.update(dict(hidden=True, available=False))
    db.session.commit()
    exit()

Ideally it would be better to directly call methods of Printer object but they are not directly accessible using threads. A future improvement could be to implement a communication mechanism that would allow call from the main process to children.