未验证 提交 b3d52d46 编写于 作者: Z zlsh80826 提交者: GitHub

Close popen pipe after used (#47053)

上级 c90dd843
......@@ -73,7 +73,9 @@ def avx_supported():
has_avx = False
if sysstr == 'linux':
try:
has_avx = os.popen('cat /proc/cpuinfo | grep -i avx').read() != ''
pipe = os.popen('cat /proc/cpuinfo | grep -i avx')
has_avx = pipe.read() != ''
pipe.close()
except Exception as e:
sys.stderr.write(
'Can not get the AVX flag from /proc/cpuinfo.\n'
......@@ -82,10 +84,9 @@ def avx_supported():
return has_avx
elif sysstr == 'darwin':
try:
has_avx = (
os.popen('sysctl machdep.cpu.features | grep -i avx').read()
!= ''
)
pipe = os.popen('sysctl machdep.cpu.features | grep -i avx')
has_avx = pipe.read() != ''
pipe.close()
except Exception as e:
sys.stderr.write(
'Can not get the AVX flag from machdep.cpu.features.\n'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册