 Chromium Code Reviews
 Chromium Code Reviews Issue 1847693004:
  Fix hanging issue with git map-branches.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
    
  
    Issue 1847693004:
  Fix hanging issue with git map-branches.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master| Index: git_cl.py | 
| diff --git a/git_cl.py b/git_cl.py | 
| index 59e412123fcd73404fddc29c1e6fd0245c66440c..cf29958353055ec8e813000ab775bb17b9b68436 100755 | 
| --- a/git_cl.py | 
| +++ b/git_cl.py | 
| @@ -15,6 +15,7 @@ import glob | 
| import httplib | 
| import json | 
| import logging | 
| +import multiprocessing | 
| import optparse | 
| import os | 
| import Queue | 
| @@ -1715,7 +1716,11 @@ def get_cl_statuses( | 
| # Process one branch synchronously to work through authentication, then | 
| # spawn processes to process all the other branches in parallel. | 
| if branches: | 
| - fetch = lambda branch: fetch_cl_status(branch, auth_config=auth_config) | 
| + def fetch(branch): | 
| 
Matt Giuca
2016/03/31 03:27:20
This should be at the top of the function (style).
 
calamity
2016/04/01 03:42:24
I miss the lambda already.
 | 
| + if not branch: | 
| + return None | 
| 
Matt Giuca
2016/03/31 03:27:20
Blank line after return.
 
calamity
2016/04/01 03:42:24
Done.
 | 
| + return fetch_cl_status(branch, auth_config=auth_config) | 
| + | 
| yield fetch(branches[0]) | 
| branches_to_fetch = branches[1:] | 
| @@ -1723,13 +1728,27 @@ def get_cl_statuses( | 
| min(max_processes, len(branches_to_fetch)) | 
| if max_processes is not None | 
| else len(branches_to_fetch)) | 
| - for x in pool.imap_unordered(fetch, branches_to_fetch): | 
| - yield x | 
| + x = pool.imap_unordered(fetch, branches_to_fetch).__iter__() | 
| + | 
| + fetched_branches = set() | 
| + while True: | 
| + try: | 
| + row = x.next(timeout=5) | 
| + fetched_branches.add(row[0]) | 
| + yield row | 
| + except multiprocessing.TimeoutError: | 
| + break | 
| + | 
| + # Add any branches that failed to fetch. | 
| + for b in set(branches_to_fetch) - fetched_branches: | 
| + cl = Changelist(branchref=b, auth_config=auth_config) | 
| + yield (b, cl.GetIssueURL() if b else None, 'error') | 
| + | 
| else: | 
| # Do not use GetApprovingReviewers(), since it requires an HTTP request. | 
| for b in branches: | 
| cl = Changelist(branchref=b, auth_config=auth_config) | 
| - url = cl.GetIssueURL() | 
| + url = cl.GetIssueURL() if b else None | 
| yield (b, url, 'waiting' if url else 'error') |