mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
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:
parent
3c0cf05901
commit
978a9afc6a
10 changed files with 104 additions and 10 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue