From ae57f8da7a03ed0ac3640fc2edaa46a5ee30aa58 Mon Sep 17 00:00:00 2001 From: Kas-tle <26531652+Kas-tle@users.noreply.github.com> Date: Wed, 22 Jun 2022 16:25:02 +0000 Subject: [PATCH] Limit concurent jobs to prevent lockup --- converter.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/converter.sh b/converter.sh index 0d3c2d1..9b6dfb7 100755 --- a/converter.sh +++ b/converter.sh @@ -50,6 +50,10 @@ user_input () { fi } +wait_for_jobs () { + while test $(jobs -p | wc -w) -ge "$((2*$(nproc)))"; do wait -n; done +} + # ensure input pack exists if ! test -f "${1}"; then status_message error "Input resource pack ${1} is not in this directory" @@ -890,6 +894,7 @@ do status_message completion "${gid} converted\n$(ProgressBar ${tot_pos} ${_end})" echo } + wait_for_jobs convert_model ${file} ${gid} ${generated} & done < all.csv