]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 86077 via svnmerge from
authorBrian Curtin <brian.curtin@gmail.com>
Mon, 1 Nov 2010 05:15:55 +0000 (05:15 +0000)
committerBrian Curtin <brian.curtin@gmail.com>
Mon, 1 Nov 2010 05:15:55 +0000 (05:15 +0000)
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.
........

Lib/multiprocessing/__init__.py
Lib/test/test_multiprocessing.py

index 0031a5e94ffad5fc54eb8c444eba98b3b5c90c96..bbdad809dc92bc590ee49cc01cb092c157f3e3e3 100644 (file)
@@ -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:
index 693026227fdbc88c232c32501b014a96891d90c8..ac02d5ab250e4097e81cf47e5b2f98f83231474c 100644 (file)
@@ -1259,7 +1259,11 @@ class _TestManagerRestart(BaseTestCase):
         authkey = os.urandom(32)
         manager = QueueManager(
             address=('localhost', 0), authkey=authkey, serializer=SERIALIZER)
-        addr = manager.get_server().address
+        srvr = manager.get_server()
+        addr = srvr.address
+        # Close the connection.Listener socket which gets opened as a part
+        # of manager.get_server(). It's not needed for the test.
+        srvr.listener.close()
         manager.start()
 
         p = self.Process(target=self._putter, args=(manager.address, authkey))