Skip to content

Commit

Permalink
Merge pull request #134 from DSACMS/timeout-handle
Browse files Browse the repository at this point in the history
Fix Bug With Unhandled Timeout Exception
  • Loading branch information
IsaacMilarky authored Apr 18, 2024
2 parents 716e9ad + b3c9d12 commit 3493436
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 2 additions & 5 deletions scripts/metricsLib/metrics_data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,8 @@ def hit_metric(self, params=None):
return response

def get_values(self,params=None, oss_entity=None):
try:
r = self.hit_metric(params=params)
except TimeoutError as e:
print(f"Request timeout out for metric {self.name}: {e}")
return {}

r = self.hit_metric(params=params)

path = oss_entity.get_path_to_resource_data(self.name, fmt=self.format)

Expand Down
10 changes: 9 additions & 1 deletion scripts/metricsLib/oss_metric_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,15 @@ def apply_metric_and_store_data(self, metric, *args, **kwargs):
params = self.get_parameters_for_metric(metric)

kwargs['params'] = params
self.store_metrics(metric.get_values(*args, **kwargs))

try:
self.store_metrics(metric.get_values(*args, **kwargs))
except TimeoutError as e:
print(f"Timeout for repo {self.name} with metric {metric.name}")
print(f"Error: {e}")
except ConnectionError as e:
print(f"Connection error for repo {self.name} with metric {metric.name}")
print(f"Error: {e}")


class Repository(OSSEntity):
Expand Down

0 comments on commit 3493436

Please sign in to comment.