Created
February 18, 2021 04:46
-
-
Save orcaman/0f4a389b0dcbdc0df6c129bfe150008c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with concurrent.futures.ThreadPoolExecutor(max_workers=MAX_PROC) as executor: | |
for entity_to_load in entities_to_load: | |
data_list = entities_to_load[entity_to_load] | |
batches = chunks(data_list, 25) | |
for batch in batches: | |
futures.append(executor.submit(dal.dynamo.load_batch, entity_to_load, batch)) | |
for future in concurrent.futures.as_completed(futures): | |
results.append(future.result()) | |
def chunks(lst, n): | |
"""Yield successive n-sized chunks from lst.""" | |
for i in range(0, len(lst), n): | |
yield lst[i:i + n] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment