Skip to content

Commit

Permalink
Merge pull request #27 from ubuntu/pass-on-urlerror
Browse files Browse the repository at this point in the history
Do not traceback on a urlerror when fetching autopkgtest queues
  • Loading branch information
murraybd authored Sep 28, 2023
2 parents 4f5519c + 724dcc6 commit 0501741
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions metrics/collectors/autopkgtest/autopkgtest_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@

class AutopkgtestMetrics(Metric):
def fetch(self, url):
with urllib.request.urlopen(url) as resp:
return json.load(resp)
try:
with urllib.request.urlopen(url) as resp:
return json.load(resp)
except urllib.error.URLError:
return []

def collect_queue_sizes(self):
data = []
for instance in ("production", "staging"):
queue_sizes = self.fetch(QUEUE_SIZE_URL[instance])
if not queue_sizes:
continue
for context in queue_sizes:
for release in queue_sizes[context]:
for arch, count in queue_sizes[context][release].items():
Expand Down

0 comments on commit 0501741

Please sign in to comment.