mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Issue #14522: Avoid duplicating socket handles in multiprocessing.connection.
Patch by sbt.
This commit is contained in:
parent
52a11f1f46
commit
df97cbe7a1
2 changed files with 6 additions and 12 deletions
|
@ -591,10 +591,7 @@ class SocketListener(object):
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
s, self._last_accepted = self._socket.accept()
|
s, self._last_accepted = self._socket.accept()
|
||||||
fd = duplicate(s.fileno())
|
return Connection(s.detach())
|
||||||
conn = Connection(fd)
|
|
||||||
s.close()
|
|
||||||
return conn
|
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self._socket.close()
|
self._socket.close()
|
||||||
|
@ -609,9 +606,7 @@ def SocketClient(address):
|
||||||
family = address_type(address)
|
family = address_type(address)
|
||||||
with socket.socket( getattr(socket, family) ) as s:
|
with socket.socket( getattr(socket, family) ) as s:
|
||||||
s.connect(address)
|
s.connect(address)
|
||||||
fd = duplicate(s.fileno())
|
return Connection(s.detach())
|
||||||
conn = Connection(fd)
|
|
||||||
return conn
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Definitions for connections based on named pipes
|
# Definitions for connections based on named pipes
|
||||||
|
@ -665,7 +660,7 @@ if sys.platform == 'win32':
|
||||||
def _finalize_pipe_listener(queue, address):
|
def _finalize_pipe_listener(queue, address):
|
||||||
sub_debug('closing listener with address=%r', address)
|
sub_debug('closing listener with address=%r', address)
|
||||||
for handle in queue:
|
for handle in queue:
|
||||||
close(handle)
|
win32.CloseHandle(handle)
|
||||||
|
|
||||||
def PipeClient(address):
|
def PipeClient(address):
|
||||||
'''
|
'''
|
||||||
|
@ -885,7 +880,3 @@ else:
|
||||||
raise
|
raise
|
||||||
if timeout is not None:
|
if timeout is not None:
|
||||||
timeout = deadline - time.time()
|
timeout = deadline - time.time()
|
||||||
|
|
||||||
|
|
||||||
# Late import because of circular import
|
|
||||||
from multiprocessing.forking import duplicate, close
|
|
||||||
|
|
|
@ -19,6 +19,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #14522: Avoid duplicating socket handles in multiprocessing.connection.
|
||||||
|
Patch by sbt.
|
||||||
|
|
||||||
- Don't Py_DECREF NULL variable in io.IncrementalNewlineDecoder.
|
- Don't Py_DECREF NULL variable in io.IncrementalNewlineDecoder.
|
||||||
|
|
||||||
- Issue #8515: Set __file__ when run file in IDLE.
|
- Issue #8515: Set __file__ when run file in IDLE.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue