Skip to content

[Build System: update-checkout] avoid multiprocessing when n is 1 #78896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions utils/update_checkout/tests/scheme_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ def setup_mock_remote(base_dir, base_config):
cwd=local_repo_path)
call_quietly(['git', 'config', 'user.email', '[email protected]'],
cwd=local_repo_path)
# any installed user certificate won't match the email address
call_quietly(['git', 'config', 'commit.gpgsign', 'false'],
cwd=local_repo_path)
call_quietly(['git', 'symbolic-ref', 'HEAD', 'refs/heads/main'],
cwd=local_repo_path)
for (i, (filename, contents)) in enumerate(v):
Expand Down
11 changes: 11 additions & 0 deletions utils/update_checkout/tests/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ def test_simple_clone(self):
repo_path = os.path.join(self.source_root, repo)
self.assertTrue(os.path.isdir(repo_path))

def test_single_threaded_clone(self):
self.call([self.update_checkout_path,
'--config', self.config_path,
'--source-root', self.source_root,
'--clone',
'-j', '1'])

for repo in self.get_all_repos():
repo_path = os.path.join(self.source_root, repo)
self.assertTrue(os.path.isdir(repo_path))


class SchemeWithMissingRepoTestCase(scheme_mock.SchemeMockTestCase):
def __init__(self, *args, **kwargs):
Expand Down
7 changes: 7 additions & 0 deletions utils/update_checkout/tests/test_update_worktree.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def test_worktree(self):
'--source-root', self.worktree_path,
'--scheme', 'main'])

def test_worktree_single_threaded(self):
self.call([self.update_checkout_path,
'--config', self.config_path,
'--source-root', self.worktree_path,
'--scheme', 'main',
'-j', '1'])

def setUp(self):
super(WorktreeTestCase, self).setUp()
self.worktree_path = os.path.join(self.workspace, WORKTREE_NAME)
Expand Down
3 changes: 3 additions & 0 deletions utils/update_checkout/update_checkout/update_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def run_parallel(fn, pool_args, n_processes=0):

if n_processes == 0:
n_processes = cpu_count() * 2
if n_processes == 1:
print("Running ``%s`` with a single process." % fn.__name__)
return [fn(args) for args in pool_args]

lk = Lock()
print("Running ``%s`` with up to %d processes." %
Expand Down