Close everything properly

This commit is contained in:
Siu Kwan Lam 2014-01-16 11:22:52 -06:00
commit b9cccbf9ae

View file

@ -12,7 +12,11 @@ http://software.intel.com/sites/default/files/m/a/b/3/4/d/41604-319433-012a.pdf
""" """
import sys, os, subprocess import sys
import os
import subprocess
import contextlib
def detect_avx_support(option='detect'): def detect_avx_support(option='detect'):
'''Detect AVX support''' '''Detect AVX support'''
@ -36,6 +40,7 @@ def detect_unix_like():
except IOError: except IOError:
return False return False
with contextlib.closing(info):
for line in info: for line in info:
if line.lstrip().startswith('flags'): if line.lstrip().startswith('flags'):
features = line.split() features = line.split()
@ -50,6 +55,8 @@ def detect_osx_like():
stdout=subprocess.PIPE) stdout=subprocess.PIPE)
except OSError: except OSError:
return False return False
with info:
features = info.stdout.read().decode('UTF8') features = info.stdout.read().decode('UTF8')
features = features.split() features = features.split()
return 'AVX1.0' in features and 'OSXSAVE' in features and 'XSAVE' in features return 'AVX1.0' in features and 'OSXSAVE' in features and 'XSAVE' in features