From 88d9f9d3acd2faf4751a6f6e4a0b50b2677e43fc Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 6 Jul 2018 03:38:07 +0200 Subject: [PATCH] Stability fixes --- platypush/backend/camera/pi.py | 14 +++++++++----- platypush/plugins/gpio/sensor/__init__.py | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/platypush/backend/camera/pi.py b/platypush/backend/camera/pi.py index 94f0a9dbf..a8c072993 100644 --- a/platypush/backend/camera/pi.py +++ b/platypush/backend/camera/pi.py @@ -73,14 +73,10 @@ class CameraPiBackend(Backend): self.camera.rotation = rotation self.camera.crop = crop self.start_recording_on_startup = start_recording_on_startup - self.redis = get_backend('redis') + self.redis = None self.redis_queue = redis_queue self._recording_thread = None - if self.start_recording_on_startup: - self.send_camera_action(self.CameraAction.START_RECORDING) - - self.logger.info('Initialized Pi camera backend') def send_camera_action(self, action, **kwargs): action = { @@ -167,6 +163,14 @@ class CameraPiBackend(Backend): def run(self): super().run() + if not self.redis: + self.redis = get_backend('redis') + + if self.start_recording_on_startup: + self.send_camera_action(self.CameraAction.START_RECORDING) + + self.logger.info('Initialized Pi camera backend') + while not self.should_stop(): try: msg = self.redis.get_message(self.redis_queue) diff --git a/platypush/plugins/gpio/sensor/__init__.py b/platypush/plugins/gpio/sensor/__init__.py index e163a33d1..30789d59d 100644 --- a/platypush/plugins/gpio/sensor/__init__.py +++ b/platypush/plugins/gpio/sensor/__init__.py @@ -34,7 +34,7 @@ class GpioSensorPlugin(Plugin): Alias for ``get_measurement`` """ - return self.get_measurement(*args, **kwargs) + return self.get_measurement(*args, **kwargs).output # vim:sw=4:ts=4:et: