diff options
author | Brian Curtin <brian.curtin@gmail.com> | 2010-11-01 05:15:55 (GMT) |
---|---|---|
committer | Brian Curtin <brian.curtin@gmail.com> | 2010-11-01 05:15:55 (GMT) |
commit | 87d86e09b5ef3fc7e007c8a6f5f0bc54e003b089 (patch) | |
tree | e7bcde6f1549a98060beeabb07ea6b1bab33fdff /Lib/multiprocessing | |
parent | 75fed81c756df510f8db24cac7fb2fcbcfea60cd (diff) | |
download | cpython-87d86e09b5ef3fc7e007c8a6f5f0bc54e003b089.zip cpython-87d86e09b5ef3fc7e007c8a6f5f0bc54e003b089.tar.gz cpython-87d86e09b5ef3fc7e007c8a6f5f0bc54e003b089.tar.bz2 |
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.
........
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r-- | Lib/multiprocessing/__init__.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/multiprocessing/__init__.py b/Lib/multiprocessing/__init__.py index 0031a5e..bbdad80 100644 --- a/Lib/multiprocessing/__init__.py +++ b/Lib/multiprocessing/__init__.py @@ -116,7 +116,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: |