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/unix_events.py | |
parent | a1611f147decd003b0ffe5d10eb011d0b8c2725e (diff) | |
download | trollius-master.tar.gz |
event loop or a transport is not explicitly closed
Diffstat (limited to 'asyncio/unix_events.py')
-rw-r--r-- | asyncio/unix_events.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/asyncio/unix_events.py b/asyncio/unix_events.py index 7e1265a..b06f1b2 100644 --- a/asyncio/unix_events.py +++ b/asyncio/unix_events.py @@ -8,6 +8,7 @@ import stat import subprocess import sys import threading +import warnings from . import base_events @@ -353,6 +354,15 @@ class _UnixReadPipeTransport(transports.ReadTransport): if not self._closing: self._close(None) + # 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 self._pipe is not None: + warnings.warn("unclosed transport %r" % self, ResourceWarning) + self._pipe.close() + def _fatal_error(self, exc, message='Fatal error on pipe transport'): # should be called by exception handler only if (isinstance(exc, OSError) and exc.errno == errno.EIO): @@ -529,6 +539,15 @@ class _UnixWritePipeTransport(transports._FlowControlMixin, # write_eof is all what we needed to close the write pipe self.write_eof() + # 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 self._pipe is not None: + warnings.warn("unclosed transport %r" % self, ResourceWarning) + self._pipe.close() + def abort(self): self._close(None) |