Compare commits
3 Commits
b93914b71f
...
40e9624a98
Author | SHA1 | Date | |
---|---|---|---|
40e9624a98 | |||
e0b15e0804 | |||
796cd3e114 |
3
gaboshlib/g_kill_all_background_jobs.sh
Normal file
3
gaboshlib/g_kill_all_background_jobs.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
functioon g_kill_all_background_jobs {
|
||||||
|
kill -9 $(jobs -p)
|
||||||
|
}
|
35
gaboshlib/g_python.sh
Normal file
35
gaboshlib/g_python.sh
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
function g_python {
|
||||||
|
|
||||||
|
unset g_python_result
|
||||||
|
g_tmp=/tmp
|
||||||
|
g_rnd=$$
|
||||||
|
# Use python in backround for multiple python commands running much faster
|
||||||
|
if [ -z "${g_python_running}" ]
|
||||||
|
then
|
||||||
|
mkdir -p ${g_tmp}/${g_rnd}
|
||||||
|
[ -p ${g_tmp}/${g_rnd}/python-in ] || mkfifo ${g_tmp}/${g_rnd}/python-in
|
||||||
|
[ -p ${g_tmp}/${g_rnd}/python-out ] || mkfifo ${g_tmp}/${g_rnd}/python-out
|
||||||
|
echo "while 1:
|
||||||
|
exec(open(\"${g_tmp}/${g_rnd}/python-in\").read())
|
||||||
|
" >${g_tmp}/${g_rnd}/python-pipeexec.py
|
||||||
|
|
||||||
|
# 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
|
||||||
|
local g_python_jobs
|
||||||
|
mapfile -t g_python_jobs < <(jobs -r)
|
||||||
|
if [[ $g_python_jobs =~ python-pipeexec.py ]]
|
||||||
|
then
|
||||||
|
echo $@ >${g_tmp}/${g_rnd}/python-in &
|
||||||
|
read -t 0.1 g_python_result <${g_tmp}/${g_rnd}/python-out
|
||||||
|
echo "RESULT: $g_python_result"
|
||||||
|
else
|
||||||
|
echo "FAIL: $g_python_result"
|
||||||
|
unset g_python_running
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user