Skip to content
Snippets Groups Projects
Commit 2f789b68 authored by Antoine Prieels's avatar Antoine Prieels
Browse files

[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: default avatarQuentin Lejeune (qle) <qle@odoo.com>
parent 40a3822a
Branches
Tags
No related merge requests found
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment