Skip to content

Commit

Permalink
Merge pull request #16 from spacetelescope/bugfix/take_exposures_erro…
Browse files Browse the repository at this point in the history
…rs_when_slow

Make take exposures tolerate slow yields
  • Loading branch information
RemiSoummer authored Jun 21, 2022
2 parents a562fda + 43cafdb commit a94130a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions catkit2/testbed/proxies/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a94130a

Please sign in to comment.