diff --git a/pr-metrics/get-pr-data.py b/pr-metrics/get-pr-data.py index 717ec4b31..45401189c 100755 --- a/pr-metrics/get-pr-data.py +++ b/pr-metrics/get-pr-data.py @@ -3,8 +3,9 @@ """Get PR data from github and pickle it.""" -import pickle import os +import requests.exceptions +import time from github import Github @@ -38,4 +39,13 @@ p.update() with open("pr-data.p", "wb") as f: - pickle.dump(prs, f) + for i, p in enumerate(prs): + for retry in range(0, 9): + try: + g.dump(p, f) + break + except requests.exceptions.ReadTimeout: + delay = 2 ** retry + print(f"timeout; sleeping {delay} s and retrying...") + time.sleep(2 ** delay) + print(f"saved {i+1}/{len(prs)}") diff --git a/pr-metrics/prs.py b/pr-metrics/prs.py index a436d7e27..decd1d87c 100644 --- a/pr-metrics/prs.py +++ b/pr-metrics/prs.py @@ -3,13 +3,18 @@ """PR data an misc common functions.""" -import pickle import datetime import os +from github import Github +prs = [] with open("pr-data.p", "rb") as f: - prs = pickle.load(f) - + g = Github() + try: + while True: + prs.append(g.load(f)) + except EOFError: + pass # Current and past core contributors, alphabetical order (sort -f). #