diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-01-29 00:55:46 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-01-29 00:55:46 +0100 |
commit | bea0a2843952629ac665f2353c0977eabad6fdc1 (patch) | |
tree | dfe35e4e0a36edfd8c654caac85d26f768b30c4e /Lib/asyncio/sslproto.py | |
parent | 6b9e2009fa257f3b7340b3e84cf0a4ed2e2c2ba9 (diff) | |
parent | fa73779b0a54211e99bd1e76511f30352c7055e9 (diff) | |
download | cpython-git-bea0a2843952629ac665f2353c0977eabad6fdc1.tar.gz |
Merge 3.4 (asyncio)
Diffstat (limited to 'Lib/asyncio/sslproto.py')
-rw-r--r-- | Lib/asyncio/sslproto.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Lib/asyncio/sslproto.py b/Lib/asyncio/sslproto.py index f2b856c40c..fc809b9831 100644 --- a/Lib/asyncio/sslproto.py +++ b/Lib/asyncio/sslproto.py @@ -418,6 +418,16 @@ class SSLProtocol(protocols.Protocol): self._in_shutdown = False self._transport = None + def _wakeup_waiter(self, exc=None): + if self._waiter is None: + return + if not self._waiter.cancelled(): + if exc is not None: + self._waiter.set_exception(exc) + else: + self._waiter.set_result(None) + self._waiter = None + def connection_made(self, transport): """Called when the low-level connection is made. @@ -489,6 +499,9 @@ class SSLProtocol(protocols.Protocol): try: if self._loop.get_debug(): logger.debug("%r received EOF", self) + + self._wakeup_waiter(ConnectionResetError) + if not self._in_handshake: keep_open = self._app_protocol.eof_received() if keep_open: @@ -552,8 +565,7 @@ class SSLProtocol(protocols.Protocol): self, exc_info=True) self._transport.close() if isinstance(exc, Exception): - if self._waiter is not None and not self._waiter.cancelled(): - self._waiter.set_exception(exc) + self._wakeup_waiter(exc) return else: raise @@ -568,9 +580,7 @@ class SSLProtocol(protocols.Protocol): compression=sslobj.compression(), ) self._app_protocol.connection_made(self._app_transport) - if self._waiter is not None: - # wait until protocol.connection_made() has been called - self._waiter._set_result_unless_cancelled(None) + self._wakeup_waiter() self._session_established = True # In case transport.write() was already called. Don't call # immediatly _process_write_backlog(), but schedule it: |