Merged revisions 86077 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r86077 | brian.curtin | 2010-11-01 00:10:44 -0500 (Mon, 01 Nov 2010) | 3 lines

  Fix some ResourceErrors.
  Use a context manager for os.popen and explicitly close a socket.
........
This commit is contained in:
Brian Curtin 2010-11-01 05:12:34 +00:00
parent 4531f8dd37
commit 9e2fadcbdd
2 changed files with 7 additions and 2 deletions

View file

@ -115,7 +115,8 @@ def cpu_count():
num = 0
elif 'bsd' in sys.platform or sys.platform == 'darwin':
try:
num = int(os.popen('sysctl -n hw.ncpu').read())
with os.popen('sysctl -n hw.ncpu') as p:
num = int(p.read())
except ValueError:
num = 0
else: