diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-04-07 20:38:52 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-04-07 20:38:52 (GMT) |
commit | df97cbe7a1866a9d16d20bed70054f344a406e08 (patch) | |
tree | 4f473a7d5e552805714b2e32529559a788af37f0 /Lib/multiprocessing/connection.py | |
parent | 52a11f1f467959d370a47f2a63b150234a6338d0 (diff) | |
download | cpython-df97cbe7a1866a9d16d20bed70054f344a406e08.zip cpython-df97cbe7a1866a9d16d20bed70054f344a406e08.tar.gz cpython-df97cbe7a1866a9d16d20bed70054f344a406e08.tar.bz2 |
Issue #14522: Avoid duplicating socket handles in multiprocessing.connection.
Patch by sbt.
Diffstat (limited to 'Lib/multiprocessing/connection.py')
-rw-r--r-- | Lib/multiprocessing/connection.py | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index 4e45443..90c1ea7 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -591,10 +591,7 @@ class SocketListener(object): 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 @@ def SocketClient(address): 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 @@ if sys.platform == 'win32': 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 @@ else: raise if timeout is not None: timeout = deadline - time.time() - - -# Late import because of circular import -from multiprocessing.forking import duplicate, close |