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

Close popen pipe after used (#47053)

上级 c90dd843
...@@ -73,7 +73,9 @@ def avx_supported(): ...@@ -73,7 +73,9 @@ def avx_supported():
has_avx = False has_avx = False
if sysstr == 'linux': if sysstr == 'linux':
try: 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: except Exception as e:
sys.stderr.write( sys.stderr.write(
'Can not get the AVX flag from /proc/cpuinfo.\n' 'Can not get the AVX flag from /proc/cpuinfo.\n'
...@@ -82,10 +84,9 @@ def avx_supported(): ...@@ -82,10 +84,9 @@ def avx_supported():
return has_avx return has_avx
elif sysstr == 'darwin': elif sysstr == 'darwin':
try: try:
has_avx = ( pipe = os.popen('sysctl machdep.cpu.features | grep -i avx')
os.popen('sysctl machdep.cpu.features | grep -i avx').read() has_avx = pipe.read() != ''
!= '' pipe.close()
)
except Exception as e: except Exception as e:
sys.stderr.write( sys.stderr.write(
'Can not get the AVX flag from machdep.cpu.features.\n' '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.
先完成此消息的编辑!
想要评论请 注册