Skip to content

Commit a94130a

Browse files
authored
Merge pull request #16 from spacetelescope/bugfix/take_exposures_errors_when_slow
Make take exposures tolerate slow yields
2 parents a562fda + 43cafdb commit a94130a

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

catkit2/testbed/proxies/camera.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,26 @@ def take_raw_exposures(self, num_exposures):
1313
first_frame_id = self.images.newest_available_frame_id
1414

1515
if was_acquiring:
16-
# Ignore first to frames to ensure the frames were taken _after_ the
16+
# Ignore first two frames to ensure the frames were taken _after_ the
1717
# call to this function. This is not necessary if the acquisition just
1818
# started.
1919
first_frame_id += 2
2020

2121
try:
22-
for i in range(num_exposures):
23-
yield self.images.get_frame(first_frame_id + i, 100000).data.copy()
22+
i = 0
23+
num_exposures_remaining = num_exposures
24+
25+
while num_exposures_remaining >= 1:
26+
try:
27+
frame = self.images.get_frame(first_frame_id + i, 100000)
28+
except RuntimeError:
29+
# The frame wasn't available anymore because we were waiting too long.
30+
continue
31+
finally:
32+
i += 1
33+
34+
yield frame.data.copy()
35+
num_exposures_remaining -= 1
2436
finally:
2537
if not was_acquiring:
2638
self.stop_acquisition()

0 commit comments

Comments
 (0)