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:
data = self.last_measurement
finally:
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:
try:
self.serial_lock.release()
except:
pass
# vim:sw=4:ts=4:et: