From b4937bbd7810201f3458eafb1040440c6cc2bf77 Mon Sep 17 00:00:00 2001 From: Wilfred Tyler Gee Date: Mon, 2 Dec 2024 11:25:53 -1000 Subject: [PATCH] Better gphoto2 readout timers. --- src/panoptes/pocs/camera/gphoto/base.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/panoptes/pocs/camera/gphoto/base.py b/src/panoptes/pocs/camera/gphoto/base.py index 7c46c9e3d..61e3d0d9b 100644 --- a/src/panoptes/pocs/camera/gphoto/base.py +++ b/src/panoptes/pocs/camera/gphoto/base.py @@ -2,7 +2,7 @@ import subprocess import time from abc import ABC -from typing import List, Dict, Union +from typing import Dict, List, Union from panoptes.utils import error from panoptes.utils.images import cr2 as cr2_utils @@ -252,14 +252,21 @@ def _poll_exposure(self, readout_args, exposure_time, timeout=None, interval=0.0 This will essentially block until the camera is done exposing, which means the super call should not have to wait. """ - self.logger.debug(f'Calling get_command_result from base gphoto2 for {self}') # Wait for and clear the _command_proc. - outs = self.get_command_result(timeout) - self.logger.debug(f'Camera response for {self}: {outs}') - self._is_exposing_event.clear() - self.logger.debug(f'Exposing event cleared for {self}') - - super()._poll_exposure(readout_args, exposure_time, timeout=timeout, interval=interval) + try: + self.logger.debug(f'Calling get_command_result from base gphoto2 for {self}') + # Wait for the exposure to complete, this blocks in gphoto2. + outs = self.get_command_result(timeout) + self.logger.debug(f'Exposure complete for {self}, getting readout') + self._readout(*readout_args) + except Exception as err: + self.logger.error(f"Error during readout on {self}: {err!r}") + self._exposure_error = repr(err) + raise err + finally: + self.logger.debug(f'Camera response for {self}: {outs}') + self._is_exposing_event.clear() + self.logger.debug(f'Exposing event cleared for {self}') def _readout(self, filename, headers, *args, **kwargs): self.logger.debug(f'Reading Canon DSLR exposure for {filename=}')