From 2f789b6863407e63f90b3a2d4cc3be09815f7002 Mon Sep 17 00:00:00 2001 From: Antoine Prieels Date: Fri, 21 Jun 2019 09:10:36 +0000 Subject: [PATCH] [FIX] hw_escpos: Avoid crashes on error Two different problems on the box and resulted in the crash of the Odoo instance running on the IoT Box: When `usblp` had troubles communicating with a printer, a NoDeviceError was raised. The `printer` variable was still set from the last time the loop was processed, so we tried to close it, resulting in an error. The code handling generic execptions was broken. closes odoo/odoo#34437 Signed-off-by: Quentin Lejeune (qle) --- addons/hw_escpos/controllers/main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/hw_escpos/controllers/main.py b/addons/hw_escpos/controllers/main.py index ea8b0fe6b74..4ae5ad004f8 100644 --- a/addons/hw_escpos/controllers/main.py +++ b/addons/hw_escpos/controllers/main.py @@ -183,13 +183,14 @@ class EscposDriver(Thread): except NoStatusError as e: print("Impossible to get the status of the printer %s" % e) except Exception as e: - self.set_status('error', e) - _logger.exception() + self.set_status('error') + _logger.exception(e) finally: if error: self.queue.put((timestamp, task, data)) if printer: printer.close() + printer = None def push_task(self,task, data = None): self.lockedstart()