summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarry Youd <harry@harryyoud.co.uk>2019-04-09 14:41:50 +0100
committerHarry Youd <harry@harryyoud.co.uk>2019-04-09 14:44:26 +0100
commit1d2b5b9dbb019510aaf3366f58ee4ea3815c7070 (patch)
treead01d42926327bf8bb31d899a3800b06f9419036
parente452d7af47f2cd4dc8cbd42dc09307fd214ea567 (diff)
downloadscripts-1d2b5b9dbb019510aaf3366f58ee4ea3815c7070.tar.gz
scripts-1d2b5b9dbb019510aaf3366f58ee4ea3815c7070.tar.bz2
scripts-1d2b5b9dbb019510aaf3366f58ee4ea3815c7070.zip
Allow capping the number of workers
Prevention for hitting GitHub's abuse detection Change-Id: Ic836e3aad4fd2152a05d862ed56e069b7fb4b55d
-rw-r--r--device-deps-regenerator/app.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/device-deps-regenerator/app.py b/device-deps-regenerator/app.py
index e08a29a..3a7ae00 100644
--- a/device-deps-regenerator/app.py
+++ b/device-deps-regenerator/app.py
@@ -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