◐ Shell
clean mode source ↗

bpo-44011: Revert "New asyncio ssl implementation (GH-17975)" by pablogsal · Pull Request #25848 · python/cpython

Expand Up @@ -273,7 +273,7 @@ async def restore(self): class Server(events.AbstractServer):
def __init__(self, loop, sockets, protocol_factory, ssl_context, backlog, ssl_handshake_timeout, ssl_shutdown_timeout=None): ssl_handshake_timeout): self._loop = loop self._sockets = sockets self._active_count = 0 Expand All @@ -282,7 +282,6 @@ def __init__(self, loop, sockets, protocol_factory, ssl_context, backlog, self._backlog = backlog self._ssl_context = ssl_context self._ssl_handshake_timeout = ssl_handshake_timeout self._ssl_shutdown_timeout = ssl_shutdown_timeout self._serving = False self._serving_forever_fut = None
Expand Down Expand Up @@ -314,8 +313,7 @@ def _start_serving(self): sock.listen(self._backlog) self._loop._start_serving( self._protocol_factory, sock, self._ssl_context, self, self._backlog, self._ssl_handshake_timeout, self._ssl_shutdown_timeout) self, self._backlog, self._ssl_handshake_timeout)
def get_loop(self): return self._loop Expand Down Expand Up @@ -469,7 +467,6 @@ def _make_ssl_transport( *, server_side=False, server_hostname=None, extra=None, server=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, call_connection_made=True): """Create SSL transport.""" raise NotImplementedError Expand Down Expand Up @@ -972,7 +969,6 @@ async def create_connection( proto=0, flags=0, sock=None, local_addr=None, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, happy_eyeballs_delay=None, interleave=None): """Connect to a TCP server.
Expand Down Expand Up @@ -1008,10 +1004,6 @@ async def create_connection( raise ValueError( 'ssl_handshake_timeout is only meaningful with ssl')
if ssl_shutdown_timeout is not None and not ssl: raise ValueError( 'ssl_shutdown_timeout is only meaningful with ssl')
if happy_eyeballs_delay is not None and interleave is None: # If using happy eyeballs, default to interleave addresses by family interleave = 1 Expand Down Expand Up @@ -1087,8 +1079,7 @@ async def create_connection(
transport, protocol = await self._create_connection_transport( sock, protocol_factory, ssl, server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) ssl_handshake_timeout=ssl_handshake_timeout) if self._debug: # Get the socket from the transport because SSL transport closes # the old socket and creates a new SSL socket Expand All @@ -1100,8 +1091,7 @@ async def create_connection( async def _create_connection_transport( self, sock, protocol_factory, ssl, server_hostname, server_side=False, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): ssl_handshake_timeout=None):
sock.setblocking(False)
Expand All @@ -1112,8 +1102,7 @@ async def _create_connection_transport( transport = self._make_ssl_transport( sock, protocol, sslcontext, waiter, server_side=server_side, server_hostname=server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) ssl_handshake_timeout=ssl_handshake_timeout) else: transport = self._make_socket_transport(sock, protocol, waiter)
Expand Down Expand Up @@ -1204,8 +1193,7 @@ async def _sendfile_fallback(self, transp, file, offset, count): async def start_tls(self, transport, protocol, sslcontext, *, server_side=False, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): ssl_handshake_timeout=None): """Upgrade transport to TLS.
Return a new transport that *protocol* should start using Expand All @@ -1228,7 +1216,6 @@ async def start_tls(self, transport, protocol, sslcontext, *, self, protocol, sslcontext, waiter, server_side, server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout, call_connection_made=False)
# Pause early so that "ssl_protocol.data_received()" doesn't Expand Down Expand Up @@ -1427,7 +1414,6 @@ async def create_server( reuse_address=None, reuse_port=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, start_serving=True): """Create a TCP server.
Expand All @@ -1451,10 +1437,6 @@ async def create_server( raise ValueError( 'ssl_handshake_timeout is only meaningful with ssl')
if ssl_shutdown_timeout is not None and ssl is None: raise ValueError( 'ssl_shutdown_timeout is only meaningful with ssl')
if host is not None or port is not None: if sock is not None: raise ValueError( Expand Down Expand Up @@ -1527,8 +1509,7 @@ async def create_server( sock.setblocking(False)
server = Server(self, sockets, protocol_factory, ssl, backlog, ssl_handshake_timeout, ssl_shutdown_timeout) ssl, backlog, ssl_handshake_timeout) if start_serving: server._start_serving() # Skip one loop iteration so that all 'loop.add_reader' Expand All @@ -1542,23 +1523,17 @@ async def create_server( async def connect_accepted_socket( self, protocol_factory, sock, *, ssl=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): ssl_handshake_timeout=None): if sock.type != socket.SOCK_STREAM: raise ValueError(f'A Stream Socket was expected, got {sock!r}')
if ssl_handshake_timeout is not None and not ssl: raise ValueError( 'ssl_handshake_timeout is only meaningful with ssl')
if ssl_shutdown_timeout is not None and not ssl: raise ValueError( 'ssl_shutdown_timeout is only meaningful with ssl')
transport, protocol = await self._create_connection_transport( sock, protocol_factory, ssl, '', server_side=True, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) ssl_handshake_timeout=ssl_handshake_timeout) if self._debug: # Get the socket from the transport because SSL transport closes # the old socket and creates a new SSL socket Expand Down