Skip to content

Commit

Permalink
Fix error using pickle
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Rodgman <[email protected]>
  • Loading branch information
daverodgman committed Apr 6, 2023
1 parent 55dc5e5 commit 005d39e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
14 changes: 12 additions & 2 deletions pr-metrics/get-pr-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)}")
11 changes: 8 additions & 3 deletions pr-metrics/prs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
#
Expand Down

0 comments on commit 005d39e

Please sign in to comment.