Skip to content

Commit

Permalink
Add retries to healthy.
Browse files Browse the repository at this point in the history
  • Loading branch information
dboulware committed May 3, 2024
1 parent 23d9fb9 commit 6a23599
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions scos_actions/hardware/sigan_iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,22 @@ def connect(self) -> None:
"""
pass

def healthy(self, num_samples: int = 56000) -> bool:
def healthy(self, num_samples: int = 56000, retries: int = 3) -> bool:
"""Perform health check by collecting IQ samples."""
logger.debug("Performing health check.")
if not self.is_available:
return False
try:
measurement_result = self.acquire_time_domain_samples(num_samples)
data = measurement_result["data"]
except Exception as e:
logger.exception("Unable to acquire samples from device.")
return False
while True:
try:
measurement_result = self.acquire_time_domain_samples(num_samples)
data = measurement_result["data"]
break
except BaseException as e:
retries -= 1
logger.debug("Unable to acquire samples during health check. Retrying...")
if retries == 0:
logger.exception("Unable to acquire samples from device during health check.")
return False

if not len(data) == num_samples:
logger.error("Data length doesn't match request.")
Expand Down

0 comments on commit 6a23599

Please sign in to comment.