From 8a81b1c245edf4214c4461907e6f09bea7fd540d Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Mon, 15 Jan 2018 15:16:51 +0100 Subject: [PATCH] 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. --- tuhi/wacom.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tuhi/wacom.py b/tuhi/wacom.py index f39502d..0aeb37c 100644 --- a/tuhi/wacom.py +++ b/tuhi/wacom.py @@ -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):