[Python-checkins] cpython: Issue #14522: Avoid duplicating socket handles in multiprocessing.connection.

antoine.pitrou python-checkins at python.org
Sat Apr 7 22:44:37 CEST 2012


http://hg.python.org/cpython/rev/f8a92fd084c2
changeset: 76158:f8a92fd084c2
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sat Apr 07 22:38:52 2012 +0200
summary:
 Issue #14522: Avoid duplicating socket handles in multiprocessing.connection.
Patch by sbt.
files:
 Lib/multiprocessing/connection.py | 15 +++------------
 Misc/NEWS | 3 +++
 2 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py
--- a/Lib/multiprocessing/connection.py
+++ b/Lib/multiprocessing/connection.py
@@ -591,10 +591,7 @@
 
 def accept(self):
 s, self._last_accepted = self._socket.accept()
- fd = duplicate(s.fileno())
- conn = Connection(fd)
- s.close()
- return conn
+ return Connection(s.detach())
 
 def close(self):
 self._socket.close()
@@ -609,9 +606,7 @@
 family = address_type(address)
 with socket.socket( getattr(socket, family) ) as s:
 s.connect(address)
- fd = duplicate(s.fileno())
- conn = Connection(fd)
- return conn
+ return Connection(s.detach())
 
 #
 # Definitions for connections based on named pipes
@@ -665,7 +660,7 @@
 def _finalize_pipe_listener(queue, address):
 sub_debug('closing listener with address=%r', address)
 for handle in queue:
- close(handle)
+ win32.CloseHandle(handle)
 
 def PipeClient(address):
 '''
@@ -885,7 +880,3 @@
 raise
 if timeout is not None:
 timeout = deadline - time.time()
-
-
-# Late import because of circular import
-from multiprocessing.forking import duplicate, close
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -19,6 +19,9 @@
 Library
 -------
 
+- Issue #14522: Avoid duplicating socket handles in multiprocessing.connection.
+ Patch by sbt.
+
 - Don't Py_DECREF NULL variable in io.IncrementalNewlineDecoder.
 
 - Issue #8515: Set __file__ when run file in IDLE.
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /