提交 6a49e7a7 编写于 作者: G gongweibao

add timeout

上级 ceb5c99f
#!/bin/bash #!/bin/bash
command -v go >/dev/null 2>&1 command -v go >/dev/null 2>&1
if [ $? -ne 0 ]; then if [[ $? -ne 0 ]]; then
echo >&2 "Please install go https://golang.org/doc/install#install" echo >&2 "Please install go https://golang.org/doc/install#install"
exit 1 exit 1
fi fi
...@@ -13,7 +13,7 @@ cd $cur_path/../ ...@@ -13,7 +13,7 @@ cd $cur_path/../
#convert md to ipynb #convert md to ipynb
for file in */{README,README\.en}.md ; do for file in */{README,README\.en}.md ; do
~/go/bin/markdown-to-ipynb < $file > ${file%.*}".ipynb" ~/go/bin/markdown-to-ipynb < $file > ${file%.*}".ipynb"
if [ $? -ne 0 ]; then if [[ $? -ne 0 ]]; then
echo >&2 "markdown-to-ipynb $file error" echo >&2 "markdown-to-ipynb $file error"
exit 1 exit 1
fi fi
...@@ -29,7 +29,19 @@ for file in */{README,README\.en}.ipynb ; do ...@@ -29,7 +29,19 @@ for file in */{README,README\.en}.ipynb ; do
cd $(dirname $file) > /dev/null cd $(dirname $file) > /dev/null
echo "begin test $file" echo "begin test $file"
jupyter nbconvert --to python $(basename $file) --stdout | python if [[ $(dirname $file) == "08.recommender_system" ]]; then
timeout -s SIGKILL 30 bash -c \
"jupyter nbconvert --to python $(basename $file) --stdout | \
sed 's/get_ipython()\.magic(.*'\''matplotlib inline'\'')/\#matplotlib inline/g' | \
sed '/^# coding: utf-8/a\import matplotlib\nmatplotlib.use('\''Agg'\'')' | python"
else
timeout -s SIGKILL 30 bash -c "jupyter nbconvert --to python $(basename $file) --stdout | python"
fi
if [[ $? -ne 0 && $? -ne 124 && $? -ne 137 ]]; then
echo >&2 "exec $file error!"
exit 1
fi
popd > /dev/null popd > /dev/null
#break #break
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册