Skip to content

Commit

Permalink
Merge pull request #4073 from nickmango/feature/multi-processing
Browse files Browse the repository at this point in the history
Bug/Concurrency support
  • Loading branch information
nickmango authored Jul 31, 2023
2 parents 3e7ffd9 + 9c3e9af commit cb91c66
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions cla-backend/cla/models/github_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import time
import uuid
import multiprocessing
import concurrent.futures
from typing import List, Union, Optional

import falcon
Expand Down Expand Up @@ -1367,17 +1367,26 @@ def get_pull_request_commit_authors(pull_request) -> List[UserCommitSummary]:

commit_authors = []

try:
num_processes = multiprocessing.cpu_count()
cla.log.debug(f'{fn} - Number of CPUs: {num_processes}')
# try:
# num_processes = multiprocessing.cpu_count()
# cla.log.debug(f'{fn} - Number of CPUs: {num_processes}')

with multiprocessing.Pool(processes=num_processes) as pool:
commit_authors = pool.starmap(get_author_summary, [(commit, pull_request.number) for commit in pull_request.get_commits()])
# with multiprocessing.Pool(processes=num_processes) as pool:
# commit_authors = pool.starmap(get_author_summary, [(commit, pull_request.number) for commit in pull_request.get_commits()])

except Exception as e:
cla.log.warning(f'{fn} - Exception while querying pull request commits for author information: {e}')
raise e

# except Exception as e:
# cla.log.warning(f'{fn} - Exception while querying pull request commits for author information: {e}')
# raise e
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
future_to_commit = {executor.submit(get_author_summary, commit, pull_request.number): commit for commit in pull_request.get_commits()}
for future in concurrent.futures.as_completed(future_to_commit):
future_to_commit[future]
try:
commit_authors.append(future.result())
except Exception as exc:
cla.log.warning(f'{fn} - PR: {pull_request.number}, get_author_summary generated an exception: {exc}')
raise exc

return commit_authors


Expand Down

0 comments on commit cb91c66

Please sign in to comment.