Commit 1c1dcdbe authored by Joel Collins's avatar Joel Collins
Browse files

Acquire microscope lock for state and settings IO

parent 5d70d5f7
Loading
Loading
Loading
Loading
+69 −66
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@ class Microscope:
        Return:
            dict: Dictionary containing complete microscope state
        """
        with self.lock:
            state = {"camera": self.camera.state, "stage": self.stage.state}
            return state

@@ -160,6 +161,7 @@ class Microscope:
        """
        Applies a settings dictionary to the microscope. Missing parameters will be left untouched.
        """
        with self.lock:
            logging.debug("Microscope: Applying settings: {}".format(settings))

            # If attached to a camera
@@ -197,6 +199,7 @@ class Microscope:
        This is to ensure that settings for currently disconnected hardware
        don't get removed from the settings file.
        """
        with self.lock:

            settings_current = {
                "id": self.id,
@@ -341,7 +344,7 @@ class Microscope:
            )

        # Gether metadata from hardware in a greenlet
        gevent.spawn(self.add_metadata_to_capture, output, metadata, annotations, tags)
        gevent.get_hub().threadpool.spawn(self.add_metadata_to_capture, output, metadata, annotations, tags)

        logging.info(f"Finished capture to {output.file}")