diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-09-04 09:08:17 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-09-04 09:08:17 +0000 |
commit | 3f3add2bc6aafde4b257458dc6e86bc3aaffca0f (patch) | |
tree | 8e0dfd4750bb9b10a26b95b4cc2610ca34e6420d /pre_commit/xargs.py | |
parent | Adding upstream version 3.3.3. (diff) | |
download | pre-commit-3f3add2bc6aafde4b257458dc6e86bc3aaffca0f.tar.xz pre-commit-3f3add2bc6aafde4b257458dc6e86bc3aaffca0f.zip |
Adding upstream version 3.4.0.upstream/3.4.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit/xargs.py')
-rw-r--r-- | pre_commit/xargs.py | 11 |
1 files changed, 10 insertions, 1 deletions
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 @@ -25,6 +25,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: return 1 @@ -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 |