diff options
author | Neil Aspinall <mail@neilaspinall.co.uk> | 2017-12-19 19:45:42 +0000 |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2017-12-19 21:45:42 +0200 |
commit | f7686c1f5553b24e3307506a18e18f6544de94d3 (patch) | |
tree | eb732724e966a23a7837e824d39a2f7181183798 /Lib/asyncio/unix_events.py | |
parent | 4b965930e8625f77cb0e821daf5cc40e85b45f84 (diff) | |
download | cpython-git-f7686c1f5553b24e3307506a18e18f6544de94d3.tar.gz |
bpo-29970: Add timeout for SSL handshake in asyncio
10 seconds by default.
Diffstat (limited to 'Lib/asyncio/unix_events.py')
-rw-r--r-- | Lib/asyncio/unix_events.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py index 2ab6b154b1..e234458226 100644 --- a/Lib/asyncio/unix_events.py +++ b/Lib/asyncio/unix_events.py @@ -192,9 +192,11 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop): def _child_watcher_callback(self, pid, returncode, transp): self.call_soon_threadsafe(transp._process_exited, returncode) - async def create_unix_connection(self, protocol_factory, path=None, *, - ssl=None, sock=None, - server_hostname=None): + async def create_unix_connection( + self, protocol_factory, path=None, *, + ssl=None, sock=None, + server_hostname=None, + ssl_handshake_timeout=constants.SSL_HANDSHAKE_TIMEOUT): assert server_hostname is None or isinstance(server_hostname, str) if ssl: if server_hostname is None: @@ -228,11 +230,14 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop): sock.setblocking(False) transport, protocol = await self._create_connection_transport( - sock, protocol_factory, ssl, server_hostname) + sock, protocol_factory, ssl, server_hostname, + ssl_handshake_timeout=ssl_handshake_timeout) return transport, protocol - async def create_unix_server(self, protocol_factory, path=None, *, - sock=None, backlog=100, ssl=None): + async def create_unix_server( + self, protocol_factory, path=None, *, + sock=None, backlog=100, ssl=None, + ssl_handshake_timeout=constants.SSL_HANDSHAKE_TIMEOUT): if isinstance(ssl, bool): raise TypeError('ssl argument must be an SSLContext or None') @@ -283,7 +288,8 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop): server = base_events.Server(self, [sock]) sock.listen(backlog) sock.setblocking(False) - self._start_serving(protocol_factory, sock, ssl, server) + self._start_serving(protocol_factory, sock, ssl, server, + ssl_handshake_timeout=ssl_handshake_timeout) return server |