summaryrefslogtreecommitdiff
path: root/asyncio/proactor_events.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-01-29 17:32:39 +0100
committerVictor Stinner <victor.stinner@gmail.com>2015-01-29 17:32:39 +0100
commit190e78603a4ce58a2f248fdf8a3472fa1fc6c064 (patch)
tree0990f66b83b12d6466ba5042bfbb0b02442ab5e7 /asyncio/proactor_events.py
parenta1611f147decd003b0ffe5d10eb011d0b8c2725e (diff)
downloadtrollius-master.tar.gz
Python issue #23243: On Python 3.4 and newer, emit a ResourceWarning when anHEADmaster
event loop or a transport is not explicitly closed
Diffstat (limited to 'asyncio/proactor_events.py')
-rw-r--r--asyncio/proactor_events.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/asyncio/proactor_events.py b/asyncio/proactor_events.py
index 0f533a5..65de926 100644
--- a/asyncio/proactor_events.py
+++ b/asyncio/proactor_events.py
@@ -7,6 +7,8 @@ proactor is only implemented on Windows with IOCP.
__all__ = ['BaseProactorEventLoop']
import socket
+import sys
+import warnings
from . import base_events
from . import constants
@@ -74,6 +76,15 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin,
self._read_fut.cancel()
self._read_fut = 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._sock is not None:
+ warnings.warn("unclosed transport %r" % self, ResourceWarning)
+ self.close()
+
def _fatal_error(self, exc, message='Fatal error on pipe transport'):
if isinstance(exc, (BrokenPipeError, ConnectionResetError)):
if self._loop.get_debug():