Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry in sigan healthy method #120

Merged
merged 4 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
23 changes: 16 additions & 7 deletions scos_actions/hardware/sigan_iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,26 @@ 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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest putting this log message in an else statement for the if statement below as retry will not occur if retries == 0.

"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
Loading