From 1cf1e40c54025fbc2b64d12681ec9e3e96c6fb7c Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Mon, 8 Apr 2019 14:06:14 +0100 Subject: [PATCH] Added a lock to stop_preview for good measure --- openflexure_microscope/camera/pi.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openflexure_microscope/camera/pi.py b/openflexure_microscope/camera/pi.py index 634a0f11..7dd40b03 100644 --- a/openflexure_microscope/camera/pi.py +++ b/openflexure_microscope/camera/pi.py @@ -243,9 +243,10 @@ class StreamingCamera(BaseCamera): def stop_preview(self) -> bool: """Stop the on board GPU camera preview.""" - self.camera.stop_preview() - self.state['preview_active'] = False - time.sleep(0.2) + with self.lock: + self.camera.stop_preview() + self.state['preview_active'] = False + time.sleep(0.2) return True def start_recording(