Skip to content

Commit 005d39e

Browse files
committed
Fix error using pickle
Signed-off-by: Dave Rodgman <[email protected]>
1 parent 55dc5e5 commit 005d39e

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

pr-metrics/get-pr-data.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
"""Get PR data from github and pickle it."""
55

6-
import pickle
76
import os
7+
import requests.exceptions
8+
import time
89

910
from github import Github
1011

@@ -38,4 +39,13 @@
3839
p.update()
3940

4041
with open("pr-data.p", "wb") as f:
41-
pickle.dump(prs, f)
42+
for i, p in enumerate(prs):
43+
for retry in range(0, 9):
44+
try:
45+
g.dump(p, f)
46+
break
47+
except requests.exceptions.ReadTimeout:
48+
delay = 2 ** retry
49+
print(f"timeout; sleeping {delay} s and retrying...")
50+
time.sleep(2 ** delay)
51+
print(f"saved {i+1}/{len(prs)}")

pr-metrics/prs.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33

44
"""PR data an misc common functions."""
55

6-
import pickle
76
import datetime
87
import os
8+
from github import Github
99

10+
prs = []
1011
with open("pr-data.p", "rb") as f:
11-
prs = pickle.load(f)
12-
12+
g = Github()
13+
try:
14+
while True:
15+
prs.append(g.load(f))
16+
except EOFError:
17+
pass
1318

1419
# Current and past core contributors, alphabetical order (sort -f).
1520
#

0 commit comments

Comments
 (0)