Skip to content

Commit 64fe1e5

Browse files
committed
progress indicator and timeouts
1 parent e285bec commit 64fe1e5

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

scripts/fetch_updates.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def update_contribution(contribution, props):
3131
if 'download' not in contribution:
3232
contribution['download'] = contribution['source'][:contribution['source'].rfind('.')] + '.zip'
3333

34-
print(f"Updated {contribution['source']}: {contribution['lastUpdated']}")
3534

3635
def log_broken(contribution, msg):
3736
if contribution['status'] == 'VALID':
@@ -95,9 +94,16 @@ def process_contribution(contribution):
9594
contributions_list = data['contributions']
9695

9796
if index == 'all':
98-
# update all contributions
99-
with Pool() as pool:
100-
pool.map(process_contribution, contributions_list)
97+
total = len(contributions_list)
98+
completed = 0
99+
print(f"Starting processing of {total} contributions...")
100+
101+
with Pool(processes=256) as pool:
102+
for _ in pool.imap_unordered(process_contribution, contributions_list):
103+
completed += 1
104+
print(f"Progress: {completed}/{total} ({(completed/total*100):.1f}%)")
105+
106+
print("All processing complete")
101107
else:
102108
# update only contribution with id==index
103109
contribution = next((x for x in contributions_list if x['id'] == int(index)), None)

scripts/parse_and_validate_properties_txt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def read_properties_txt(properties_url):
6464
'User-Agent': 'Mozilla/5.0',
6565
'Accept': 'text/html',
6666
}
67-
r = requests.get(properties_url, headers=headers)
67+
r = requests.get(properties_url, headers=headers, timeout=30)
6868

6969
if r.status_code != 200:
7070
raise FileNotFoundError(f"status code {r.status_code} returned for url {r.url}")

0 commit comments

Comments
 (0)