From 978a9afc6af6c137065bdcf7ae4ef5450e5b2ec2 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 29 Jan 2015 17:50:58 +0100 Subject: Issue #23243, asyncio: Emit a ResourceWarning when an event loop or a transport is not explicitly closed. Close also explicitly transports in test_sslproto. --- Lib/asyncio/windows_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Lib/asyncio/windows_utils.py') diff --git a/Lib/asyncio/windows_utils.py b/Lib/asyncio/windows_utils.py index 5f8327eba63..870cd13abe6 100644 --- a/Lib/asyncio/windows_utils.py +++ b/Lib/asyncio/windows_utils.py @@ -14,6 +14,7 @@ import os import socket import subprocess import tempfile +import warnings __all__ = ['socketpair', 'pipe', 'Popen', 'PIPE', 'PipeHandle'] @@ -156,7 +157,10 @@ class PipeHandle: CloseHandle(self._handle) self._handle = None - __del__ = close + def __del__(self): + if self._handle is not None: + warnings.warn("unclosed %r" % self, ResourceWarning) + self.close() def __enter__(self): return self -- cgit v1.2.3