From 3f3add2bc6aafde4b257458dc6e86bc3aaffca0f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 4 Sep 2023 11:08:17 +0200 Subject: Adding upstream version 3.4.0. Signed-off-by: Daniel Baumann --- pre_commit/xargs.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'pre_commit/xargs.py') diff --git a/pre_commit/xargs.py b/pre_commit/xargs.py index 31be6f3..a7493c0 100644 --- a/pre_commit/xargs.py +++ b/pre_commit/xargs.py @@ -24,6 +24,14 @@ TRet = TypeVar('TRet') def cpu_count() -> int: + try: + # On systems that support it, this will return a more accurate count of + # usable CPUs for the current process, which will take into account + # cgroup limits + return len(os.sched_getaffinity(0)) + except AttributeError: + pass + try: return multiprocessing.cpu_count() except NotImplementedError: @@ -170,7 +178,8 @@ def xargs( results = thread_map(run_cmd_partition, partitions) for proc_retcode, proc_out, _ in results: - retcode = max(retcode, proc_retcode) + if abs(proc_retcode) > abs(retcode): + retcode = proc_retcode stdout += proc_out return retcode, stdout -- cgit v1.2.3