Allow capping the number of workers

Prevention for hitting GitHub's abuse detection

Change-Id: Ic836e3aad4fd2152a05d862ed56e069b7fb4b55d
This commit is contained in:
Harry Youd
2019-04-09 14:41:50 +01:00
parent e452d7af47
commit 1d2b5b9dbb

View File

@@ -1,3 +1,4 @@
import argparse
import concurrent.futures
import github
import json
@@ -6,6 +7,10 @@ import traceback
from github import Github
from base64 import b64decode
parser = argparse.ArgumentParser()
parser.add_argument('-j', '--jobs', type=int, help='Max number of workers to use. Default is none')
args = parser.parse_args()
with open('token') as f:
g = Github(f.readline().strip(), per_page=200)
@@ -65,8 +70,7 @@ n = 1
dependencies = {}
other_repos = set()
with concurrent.futures.ThreadPoolExecutor() as executor:
with concurrent.futures.ThreadPoolExecutor(max_workers=args.jobs) as executor:
for repo in g.get_organization('LineageOS').get_repos():
if '_device_' not in repo.name:
continue