From 5cfbd75250b31d8b452a03a511ea87c7dcee7804 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 5 Sep 2018 02:26:55 +0200 Subject: [PATCH] Prevent RuntimeError on lock release if lock acquisition failed --- platypush/plugins/serial/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platypush/plugins/serial/__init__.py b/platypush/plugins/serial/__init__.py index 99976c003..262dfe779 100644 --- a/platypush/plugins/serial/__init__.py +++ b/platypush/plugins/serial/__init__.py @@ -110,7 +110,10 @@ class SerialPlugin(GpioSensorPlugin): else: data = self.last_measurement finally: - self.serial_lock.release() + try: + self.serial_lock.release() + except: + pass if data: self.last_measurement = data @@ -143,7 +146,10 @@ class SerialPlugin(GpioSensorPlugin): self.logger.info('Writing {} to {}'.format(data, self.device)) ser.write(data) finally: - self.serial_lock.release() + try: + self.serial_lock.release() + except: + pass # vim:sw=4:ts=4:et: