Prevent RuntimeError on lock release if lock acquisition failed
This commit is contained in:
parent
3b8c580611
commit
5cfbd75250
1 changed files with 8 additions and 2 deletions
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue