Skip to content

Commit

Permalink
Merge pull request #120 from NTIA/HealthyRetries
Browse files Browse the repository at this point in the history
Retry in sigan healthy method
  • Loading branch information
dboulware authored May 14, 2024
2 parents 23d9fb9 + 5a503d9 commit d7ace3b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion scos_actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "10.0.1"
__version__ = "10.0.2"
24 changes: 17 additions & 7 deletions scos_actions/hardware/sigan_iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,27 @@ 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
if retries == 0:
logger.exception(
"Unable to acquire samples from device during health check."
)
return False
else:
logger.debug(
"Unable to acquire samples during health check. Retrying..."
)

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

0 comments on commit d7ace3b

Please sign in to comment.