Issue #23243, asyncio: Emit a ResourceWarning when an event loop or a transport

is not explicitly closed. Close also explicitly transports in test_sslproto.
This commit is contained in:
Victor Stinner 2015-01-29 17:50:58 +01:00
parent 3c0cf05901
commit 978a9afc6a
10 changed files with 104 additions and 10 deletions

View file

@ -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