summaryrefslogtreecommitdiffstats
path: root/Lib/socket.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-01-05 21:03:42 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-01-05 21:03:42 (GMT)
commit600232b562391d62f33dcc19c09eb9c3e9190c46 (patch)
tree37871d8858bf75a0e98bf602be889775e5048a31 /Lib/socket.py
parent7d967712b8cc35b4cc33c1a7be14ddc9baba2c97 (diff)
downloadcpython-600232b562391d62f33dcc19c09eb9c3e9190c46.zip
cpython-600232b562391d62f33dcc19c09eb9c3e9190c46.tar.gz
cpython-600232b562391d62f33dcc19c09eb9c3e9190c46.tar.bz2
Issue #7995: When calling accept() on a socket with a timeout, the returned
socket is now always non-blocking, regardless of the operating system.
Diffstat (limited to 'Lib/socket.py')
-rw-r--r--Lib/socket.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index d0da740..95901ae 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -130,7 +130,13 @@ class socket(_socket.socket):
For IP sockets, the address info is a pair (hostaddr, port).
"""
fd, addr = self._accept()
- return socket(self.family, self.type, self.proto, fileno=fd), addr
+ sock = socket(self.family, self.type, self.proto, fileno=fd)
+ # Issue #7995: if no default timeout is set and the listening
+ # socket had a (non-zero) timeout, force the new socket in blocking
+ # mode to override platform-specific socket flags inheritance.
+ if getdefaulttimeout() is None and self.gettimeout():
+ sock.setblocking(True)
+ return sock, addr
def makefile(self, mode="r", buffering=None, *,
encoding=None, errors=None, newline=None):