Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit d6ae02d

Browse files
authored
Reuse existing env var for number of parallel requests (#1479)
1 parent 77d8bcf commit d6ae02d

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

commands/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def records_equal(a, b):
7373
return ra == rb
7474

7575

76-
def call_parallel(func, args_list, max_workers=4):
76+
def call_parallel(func, args_list, max_workers=PARALLEL_REQUESTS):
7777
results = []
7878
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
7979
futures = [executor.submit(func, *args) for args in args_list]

commands/build_bundles.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121

2222
SERVER = os.getenv("SERVER")
23-
REQUESTS_PARALLEL_COUNT = int(os.getenv("REQUESTS_PARALLEL_COUNT", "8"))
2423
BUNDLE_MAX_SIZE_BYTES = int(os.getenv("BUNDLE_MAX_SIZE_BYTES", "20_000_000"))
2524
ENVIRONMENT = os.getenv("ENVIRONMENT", "local")
2625
REALM = os.getenv("REALM", "test")
@@ -48,7 +47,7 @@ def fetch_all_changesets(client):
4847
(c["bucket"], c["collection"], c["last_modified"]) for c in monitor_changeset["changes"]
4948
]
5049
all_changesets = call_parallel(
51-
lambda bid, cid, ts: client.get_changeset(bid, cid, ts), args_list, REQUESTS_PARALLEL_COUNT
50+
lambda bid, cid, ts: client.get_changeset(bid, cid, ts), args_list
5251
)
5352
return [
5453
{"bucket": bid, **changeset} for (bid, _, _), changeset in zip(args_list, all_changesets)
@@ -194,7 +193,7 @@ def build_bundles(event, context):
194193

195194
# Fetch all attachments and build "{bid}--{cid}.zip"
196195
args_list = [(f'{base_url}{r["attachment"]["location"]}',) for r in records]
197-
all_attachments = call_parallel(fetch_attachment, args_list, REQUESTS_PARALLEL_COUNT)
196+
all_attachments = call_parallel(fetch_attachment, args_list)
198197
write_zip(
199198
attachments_bundle_filename,
200199
[(f'{record["id"]}.meta.json', json.dumps(record)) for record in records]

0 commit comments

Comments
 (0)