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