Skip to content

Commit

Permalink
Add sleep in cleanup when reading out exposure to prevent bug in lvmscp
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Nov 7, 2024
1 parent 421daf8 commit 5996f29
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

* `GortObserver.observe_tile` now default to `async_readout=False`. This will block until the exposure is done, which is a more natural behaviour for an external user that is not trying to over-optimise things. The code that uses `observe_tile` in GORT (`Gort.observe()` and `ObserverOverwatcher.observe_loop_task()`) have been updated to explicitly use `async_readout=True`.

### 🔧 Fixed

* Temporary fix in the cleanup recipe for a bug in `lvmscp` caused by a quick reset after reading out a pending exposure.


## 1.0.2 - November 6, 2024

Expand Down
10 changes: 10 additions & 0 deletions src/gort/recipes/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ async def recipe(self, readout: bool = True, turn_lamps_off: bool = True):
await self.gort.guiders.stop()

if not (await self.gort.specs.are_idle()):
extra_sleep: float = 0
cotasks = []

for spec in self.gort.specs.values():
Expand All @@ -227,6 +228,7 @@ async def recipe(self, readout: bool = True, turn_lamps_off: bool = True):
if await spec.is_reading():
self.gort.log.warning(f"{spec.name} is reading. Waiting.")
cotasks.append(self._wait_until_spec_is_idle(spec))
extra_sleep = 10
elif await spec.is_exposing():
self.gort.log.warning(f"{spec.name} is exposing. Aborting.")
cotasks.append(spec.abort())
Expand All @@ -239,9 +241,17 @@ async def recipe(self, readout: bool = True, turn_lamps_off: bool = True):
self.gort.log.warning(f"{msg} Reading it.")
cotasks.append(spec.actor.commands.read())
cotasks.append(self._wait_until_spec_is_idle(spec))
extra_sleep = 10

try:
await asyncio.gather(*cotasks)

# HACK: lvmscp says the controller is idle before it actually
# writes the image to disk. If we reset too fast (as we are going
# to do just after this) that will crash the exposures.
# I'll fix that in lvmscp (promise) but for now we add a sleep here
# to allows the images to post-process and write before resetting.
await asyncio.sleep(extra_sleep)
except Exception as ee:
self.gort.log.error(f"Error during cleanup: {ee}")
self.gort.log.warning("Resetting the spectrographs.")
Expand Down

0 comments on commit 5996f29

Please sign in to comment.