Compare commits

..

No commits in common. "39b3a944dd276120800c959b3411539c2113d346" and "356267418bf8a1bfc6f46af11d1e259e12b89a33" have entirely different histories.

2 changed files with 9 additions and 28 deletions

View File

@ -1,4 +1,3 @@
function g_kill_all_background_jobs {
kill -9 $(jobs -p) >/dev/null 2>&1
kill -9 $(jobs -p)
}

View File

@ -13,40 +13,22 @@ function g_python {
exec(open(\"${g_tmp}/${g_rnd}/python-in\").read())
" >${g_tmp}/${g_rnd}/python-pipeexec.py
# python stream channel
{ python3 -u ${g_tmp}/${g_rnd}/python-pipeexec.py >${g_tmp}/${g_rnd}/python-out 2>${g_tmp}/${g_rnd}/python-error & }
# bc stream channel
{ python3 -u ${g_tmp}/${g_rnd}/python-pipeexec.py >${g_tmp}/${g_rnd}/python-out 2>&1 & }
g_python_running="true"
fi
# do python
echo "$@" >${g_tmp}/${g_rnd}/python-in &
sleep 0.02
local g_python_jobs
mapfile -t g_python_jobs < <(jobs -r)
if ! [[ $g_python_jobs =~ python-pipeexec.py ]]
if [[ $g_python_jobs =~ python-pipeexec.py ]]
then
g_echo_error "$(cat ${g_tmp}/${g_rnd}/python-error)"
unset g_python_running
return 1
fi
if [ -n "$g_python_waitforoutput" ]
then
until [ -n "$g_python_result" ]
do
echo $@ >${g_tmp}/${g_rnd}/python-in &
read -t 0.1 g_python_result <${g_tmp}/${g_rnd}/python-out
[ -s "${g_tmp}/${g_rnd}/python-error" ] && break
done
unset g_python_waitforoutput
echo "RESULT: $g_python_result"
else
read -t0.2 g_python_result <${g_tmp}/${g_rnd}/python-out
fi
if [ -s "${g_tmp}/${g_rnd}/python-error" ]
then
g_echo_error "$(cat ${g_tmp}/${g_rnd}/python-error)"
return 1
echo "FAIL: $g_python_result"
unset g_python_running
fi
}