Skip to content

Commit 23474f9

Browse files
Merge pull request #84825 from charles-zablit/charles-zablit/update-checkout/force-verbose-python-3.9
[update-checkout] force verbose mode if python 3.9
2 parents 611102b + 7508a92 commit 23474f9

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

utils/update_checkout/update_checkout/parallel_runner.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(
4848
):
4949
self._monitor_polling_period = 0.1
5050
if n_processes == 0:
51-
n_processes = ParallelRunner._max_processes()
51+
n_processes = cpu_count() * 2
5252
self._terminal_width = shutil.get_terminal_size().columns
5353
self._n_processes = n_processes
5454
self._pool_args = pool_args
@@ -140,13 +140,3 @@ def check_results(results, op) -> int:
140140
if r.stderr:
141141
print(r.stderr.decode())
142142
return fail_count
143-
144-
@staticmethod
145-
def _max_processes() -> int:
146-
if sys.version_info.minor < 10:
147-
# On Python < 3.10, https://bugs.python.org/issue46391 causes
148-
# Pool.map and its variants to hang. Limiting the number of
149-
# processes fixes the issue.
150-
return int(cpu_count() * 1.25)
151-
else:
152-
return cpu_count() * 2

utils/update_checkout/update_checkout/update_checkout.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -809,20 +809,18 @@ def main():
809809
sys.exit(1)
810810

811811
if is_unix_sock_path_too_long():
812-
print(
813-
f"TEMPDIR={tempfile.gettempdir()} is too long and multiprocessing "
814-
"sockets will exceed the size limit. Falling back to verbose mode."
815-
)
812+
if not args.dump_hashes and not args.dump_hashes_config:
813+
# Do not print anything other than the json dump.
814+
print(
815+
f"TEMPDIR={tempfile.gettempdir()} is too long and multiprocessing "
816+
"sockets will exceed the size limit. Falling back to verbose mode."
817+
)
818+
args.verbose = True
819+
if sys.version_info.minor < 10:
820+
if not args.dump_hashes and not args.dump_hashes_config:
821+
# Do not print anything other than the json dump.
822+
print("Falling back to verbose mode due to a Python 3.9 limitation.")
816823
args.verbose = True
817-
elif (
818-
sys.version_info.minor < 10
819-
and args.n_processes > ParallelRunner._max_processes()
820-
):
821-
print(
822-
"Falling back to verbose mode due to a Python 3.9 limitation. "
823-
f"Lower `-j` below {ParallelRunner._max_processes()} to use non verbose mode."
824-
)
825-
args._verbose = True
826824

827825
clone = args.clone
828826
clone_with_ssh = args.clone_with_ssh

0 commit comments

Comments
 (0)