diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-01-29 17:32:39 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-01-29 17:32:39 +0100 |
commit | 190e78603a4ce58a2f248fdf8a3472fa1fc6c064 (patch) | |
tree | 0990f66b83b12d6466ba5042bfbb0b02442ab5e7 /asyncio/sslproto.py | |
parent | a1611f147decd003b0ffe5d10eb011d0b8c2725e (diff) | |
download | trollius-master.tar.gz |
event loop or a transport is not explicitly closed
Diffstat (limited to 'asyncio/sslproto.py')
-rw-r--r-- | asyncio/sslproto.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/asyncio/sslproto.py b/asyncio/sslproto.py index fc809b9..235855e 100644 --- a/asyncio/sslproto.py +++ b/asyncio/sslproto.py @@ -1,4 +1,6 @@ import collections +import sys +import warnings try: import ssl except ImportError: # pragma: no cover @@ -295,6 +297,7 @@ class _SSLProtocolTransport(transports._FlowControlMixin, self._loop = loop self._ssl_protocol = ssl_protocol self._app_protocol = app_protocol + self._closed = False def get_extra_info(self, name, default=None): """Get optional transport information.""" @@ -308,8 +311,18 @@ class _SSLProtocolTransport(transports._FlowControlMixin, protocol's connection_lost() method will (eventually) called with None as its argument. """ + self._closed = True self._ssl_protocol._start_shutdown() + # On Python 3.3 and older, objects with a destructor part of a reference + # cycle are never destroyed. It's not more the case on Python 3.4 thanks + # to the PEP 442. + if sys.version_info >= (3, 4): + def __del__(self): + if not self._closed: + warnings.warn("unclosed transport %r" % self, ResourceWarning) + self.close() + def pause_reading(self): """Pause the receiving end. |