Prevent RuntimeError on lock release if lock acquisition failed

This commit is contained in:
Fabio Manganiello 2018-09-05 02:26:55 +02:00
parent 3b8c580611
commit 5cfbd75250

View file

@ -110,7 +110,10 @@ class SerialPlugin(GpioSensorPlugin):
else: else:
data = self.last_measurement data = self.last_measurement
finally: finally:
try:
self.serial_lock.release() self.serial_lock.release()
except:
pass
if data: if data:
self.last_measurement = data self.last_measurement = data
@ -143,7 +146,10 @@ class SerialPlugin(GpioSensorPlugin):
self.logger.info('Writing {} to {}'.format(data, self.device)) self.logger.info('Writing {} to {}'.format(data, self.device))
ser.write(data) ser.write(data)
finally: finally:
try:
self.serial_lock.release() self.serial_lock.release()
except:
pass
# vim:sw=4:ts=4:et: # vim:sw=4:ts=4:et: