From ff9e1c71a704fd8c29ec10b789f76a4042ba1ff9 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 23 Dec 2019 18:48:01 +0100 Subject: [PATCH] Prevent race condition on self._drive_thread = None --- platypush/plugins/gpio/zeroborg/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platypush/plugins/gpio/zeroborg/__init__.py b/platypush/plugins/gpio/zeroborg/__init__.py index 87e328ee..9492aa5f 100644 --- a/platypush/plugins/gpio/zeroborg/__init__.py +++ b/platypush/plugins/gpio/zeroborg/__init__.py @@ -125,8 +125,9 @@ class GpioZeroborgPlugin(Plugin): self._direction = direction.lower() if not self._drive_thread: - self._drive_thread = threading.Thread(target=_run) - self._drive_thread.start() + drive_thread = threading.Thread(target=_run) + drive_thread.start() + self._drive_thread = drive_thread get_bus().post(ZeroborgDriveEvent(direction=self._direction, motors=self.directions[self._direction])) return {'status': 'running', 'direction': direction}