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
1 changed files with 8 additions and 2 deletions

View File

@ -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: