From cd076ba1b0be061d4446e47f68b3ec53122ce95c Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Tue, 9 Jan 2024 21:05:36 +0000 Subject: [PATCH] [git_cl] Limit number of concurrent connections When git cl status is executed, it's possible that Gerrit will throttle some requests. This change sets upper bound of concurrent connections to 20. R=gavinmak@google.com Fixed: b/319248186 Change-Id: I51b1d87109447efc8c86d615f12bcafe8c317a90 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5181274 Commit-Queue: Josip Sokcevic Reviewed-by: Gavin Mak --- git_cl.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/git_cl.py b/git_cl.py index daa02d5df..496e8d50b 100755 --- a/git_cl.py +++ b/git_cl.py @@ -81,6 +81,7 @@ GIT_HASH_RE = re.compile(r'\b([a-f0-9]{6})[a-f0-9]{34}\b', flags=re.I) GITCOOKIES_REDACT_RE = re.compile(r'1/.*') MAX_ATTEMPTS = 3 +MAX_CONCURRENT_CONNECTION = 20 # The maximum number of traces we will keep. Multiplied by 3 since we store # 3 files per trace. @@ -3926,8 +3927,8 @@ def get_cl_statuses(changes, fine_grained, max_processes=None): Otherwise, simply indicate if there's a matching url for the given branches. If max_processes is specified, it is used as the maximum number of processes - to spawn to fetch CL status from the server. Otherwise 1 process per branch is - spawned. + to spawn to fetch CL status from the server. Otherwise 1 process per branch + is spawned, up to max of MAX_CONCURRENT_CONNECTION. See GetStatus() for a list of possible statuses. """ @@ -3956,7 +3957,7 @@ def get_cl_statuses(changes, fine_grained, max_processes=None): cl.GetIssue()) raise - threads_count = len(changes) + threads_count = min(MAX_CONCURRENT_CONNECTION, len(changes)) if max_processes: threads_count = max(1, min(threads_count, max_processes)) logging.debug('querying %d CLs using %d threads', len(changes),