Skip to content

Commit

Permalink
Max workers 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jrlegrand committed Oct 4, 2024
1 parent c6a9e0c commit 243f274
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions airflow/dags/sagerx.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,16 @@ def get_api(url):
def parallel_api_calls(api_calls:list) -> list:
from concurrent.futures import ThreadPoolExecutor, as_completed
output = []
with ThreadPoolExecutor(max_workers=32) as executor:
with ThreadPoolExecutor(max_workers=3) as executor:
futures = {executor.submit(get_api, api_call):api_call for api_call in api_calls}

for future in as_completed(futures):
url = futures[future]
response = future.result()
if not len(response) == 0:
output.append({"url":url,"response":response})
else:
print(f"Empty response for url: {url}")
if len(output) % 1000 == 0:
print(f'MILESTONE {len(output)}')
# else:
# print(f"Empty response for url: {url}")
return output

0 comments on commit 243f274

Please sign in to comment.