Make sure we retrieve the data atomically

Ignore any requests to sync the device while the previous sync is still
ongoing. This should be the exception anyway, we shouldn't get another
"connected" signal from the device while we're syncing.
pull/2/merge
Benjamin Tissoires 2018-01-15 15:16:51 +01:00
parent f88a5b2222
commit 8a81b1c245
1 changed files with 8 additions and 0 deletions

View File

@ -136,6 +136,8 @@ class WacomDevice(GObject.Object):
self.height = WACOM_SLATE_HEIGHT
self.name = device.name
self._is_running = False
device.connect_gatt_value(WACOM_CHRC_LIVE_PEN_DATA_UUID,
self._on_pen_data_changed)
device.connect_gatt_value(WACOM_OFFLINE_CHRC_PEN_DATA_UUID,
@ -571,10 +573,16 @@ class WacomDevice(GObject.Object):
logger.warning("no data, please make sure the LED is blue and the button is pressed to switch it back to green")
def run(self):
if self._is_running:
logger.error('{}: already synching, ignoring this request'.format(self.device.address))
return
logger.debug('{}: starting'.format(self.device.address))
self._is_running = True
try:
self.retrieve_data()
finally:
self._is_running = False
self.emit("done")
def start(self):