@@ -15,7 +15,7 @@ def __init__(
1515 fn : Callable ,
1616 running_tasks : ListProxy ,
1717 updated_repos : ValueProxy ,
18- lock : Lock
18+ lock : Lock ,
1919 ):
2020 self .fn = fn
2121 self .running_tasks = running_tasks
@@ -48,13 +48,7 @@ def __init__(
4848 ):
4949 self ._monitor_polling_period = 0.1
5050 if n_processes == 0 :
51- if sys .version_info .minor < 10 :
52- # On Python < 3.10, https://bugs.python.org/issue46391 causes
53- # Pool.map and its variants to hang. Limiting the number of
54- # processes fixes the issue.
55- n_processes = int (cpu_count () * 1.25 )
56- else :
57- n_processes = cpu_count () * 2
51+ n_processes = ParallelRunner ._max_processes ()
5852 self ._terminal_width = shutil .get_terminal_size ().columns
5953 self ._n_processes = n_processes
6054 self ._pool_args = pool_args
@@ -106,7 +100,7 @@ def _monitor(self):
106100 self ._lock .release ()
107101
108102 if current_line != last_output :
109- truncated = ( f"{ self ._output_prefix } [{ updated_repos } /{ self ._nb_repos } ] ({ current_line } )" )
103+ truncated = f"{ self ._output_prefix } [{ updated_repos } /{ self ._nb_repos } ] ({ current_line } )"
110104 if len (truncated ) > self ._terminal_width :
111105 ellipsis_marker = " ..."
112106 truncated = (
@@ -147,3 +141,12 @@ def check_results(results, op) -> int:
147141 print (r .stderr .decode ())
148142 return fail_count
149143
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
0 commit comments