提交 93cd5745 编写于 作者: Y yejianwu

add file lock to adb_run

上级 cad35db5
...@@ -109,12 +109,13 @@ RUN apt-get install -y --no-install-recommends \ ...@@ -109,12 +109,13 @@ RUN apt-get install -y --no-install-recommends \
# Install tools # Install tools
RUN pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com setuptools RUN pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com setuptools
RUN pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com tensorflow==1.4.0 \ RUN pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com tensorflow==1.6.0 \
scipy \ scipy \
jinja2 \ jinja2 \
pyyaml \ pyyaml \
sh \ sh==1.12.14 \
pycodestyle pycodestyle==2.4.0 \
filelock
# Download tensorflow tools # Download tensorflow tools
RUN wget http://cnbj1-inner-fds.api.xiaomi.net/mace/tool/transform_graph && \ RUN wget http://cnbj1-inner-fds.api.xiaomi.net/mace/tool/transform_graph && \
......
import sh import falcon_cli
import filelock
import re import re
import sh
import time import time
import falcon_cli
################################ ################################
...@@ -85,28 +86,33 @@ def adb_run(serialno, ...@@ -85,28 +86,33 @@ def adb_run(serialno,
print( print(
"=====================================================================" "====================================================================="
) )
print("Run on device: %s, %s, %s" % (serialno, props["ro.board.platform"], lock_path = "/tmp/device-lock-%s" % serialno
props["ro.product.model"])) print("Try to lock ", lock_path)
sh.adb("-s", serialno, "shell", "rm -rf %s" % device_bin_path) with filelock.FileLock(lock_path, timeout=3600):
sh.adb("-s", serialno, "shell", "mkdir -p %s" % device_bin_path) print("Run on device: %s, %s, %s" % (serialno,
print("Push %s to %s" % (host_bin_full_path, device_bin_full_path)) props["ro.board.platform"],
sh.adb("-s", serialno, "push", host_bin_full_path, device_bin_full_path) props["ro.product.model"]))
print("Run %s" % device_bin_full_path) sh.adb("-s", serialno, "shell", "rm -rf %s" % device_bin_path)
stdout_buff = [] sh.adb("-s", serialno, "shell", "mkdir -p %s" % device_bin_path)
process_output = make_output_processor(stdout_buff) print("Push %s to %s" % (host_bin_full_path, device_bin_full_path))
p = sh.adb( sh.adb("-s", serialno, "push", host_bin_full_path,
"-s", device_bin_full_path)
serialno, print("Run %s" % device_bin_full_path)
"shell", stdout_buff = []
"MACE_OUT_OF_RANGE_CHECK=%d MACE_OPENCL_PROFILING=%d " process_output = make_output_processor(stdout_buff)
"MACE_CPP_MIN_VLOG_LEVEL=%d %s %s" % p = sh.adb(
(out_of_range_check, opencl_profiling, vlog_level, "-s",
device_bin_full_path, args), serialno,
_out=process_output, "shell",
_bg=True, "MACE_OUT_OF_RANGE_CHECK=%d MACE_OPENCL_PROFILING=%d "
_err_to_out=True) "MACE_CPP_MIN_VLOG_LEVEL=%d %s %s" %
p.wait() (out_of_range_check, opencl_profiling, vlog_level,
return "".join(stdout_buff) device_bin_full_path, args),
_out=process_output,
_bg=True,
_err_to_out=True)
p.wait()
return "".join(stdout_buff)
################################ ################################
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册