diff --git a/catkit2/testbed/proxies/camera.py b/catkit2/testbed/proxies/camera.py index a377d1006..bb1aa45bb 100644 --- a/catkit2/testbed/proxies/camera.py +++ b/catkit2/testbed/proxies/camera.py @@ -13,14 +13,26 @@ def take_raw_exposures(self, num_exposures): first_frame_id = self.images.newest_available_frame_id if was_acquiring: - # Ignore first to frames to ensure the frames were taken _after_ the + # Ignore first two frames to ensure the frames were taken _after_ the # call to this function. This is not necessary if the acquisition just # started. first_frame_id += 2 try: - for i in range(num_exposures): - yield self.images.get_frame(first_frame_id + i, 100000).data.copy() + i = 0 + num_exposures_remaining = num_exposures + + while num_exposures_remaining >= 1: + try: + frame = self.images.get_frame(first_frame_id + i, 100000) + except RuntimeError: + # The frame wasn't available anymore because we were waiting too long. + continue + finally: + i += 1 + + yield frame.data.copy() + num_exposures_remaining -= 1 finally: if not was_acquiring: self.stop_acquisition()