diff --git a/archon/actor/delegate.py b/archon/actor/delegate.py index 898d798..e6577e9 100644 --- a/archon/actor/delegate.py +++ b/archon/actor/delegate.py @@ -352,6 +352,10 @@ async def readout( except Exception as err: return self.fail(f"Failed reading out: {err}") + if len(c_fdata) == 0: + self.command.error("No data was fetched.") + return False + self.command.debug(f"Readout completed in {time()-t0:.1f} seconds.") if write is False: @@ -391,8 +395,7 @@ async def readout( for fd in fdata ] - if len(fdata) > 0: - self.last_exposure_no = fdata[0]["exposure_no"] + self.last_exposure_no = fdata[0]["exposure_no"] # Prepare checksum information. write_checksum: bool = self.config["checksum.write"] diff --git a/tests/actor/test_delegate.py b/tests/actor/test_delegate.py index 4506523..2c603ad 100644 --- a/tests/actor/test_delegate.py +++ b/tests/actor/test_delegate.py @@ -264,6 +264,25 @@ async def test_delegate_shutter_fails(delegate: ExposureDelegate, mocker): assert result is False +async def test_delegate_readout_no_fetch_data(delegate: ExposureDelegate): + command = Command("", actor=delegate.actor) + result = await delegate.expose( + command, + [delegate.actor.controllers["sp1"]], + flavour="object", + exposure_time=0.01, + readout=False, + ) + assert result is True + + assert delegate.expose_data + delegate.expose_data.controllers = [] + + result = await delegate.readout(command) + assert result is False + assert delegate.command.replies[-1].body["error"] == "No data was fetched." + + @pytest.mark.parametrize("window_mode", ["test_mode", "default"]) async def test_delegate_expose_window_mode(delegate: ExposureDelegate, window_mode): command = Command("", actor=delegate.actor)