mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
GH-106684: raise ResourceWarning
when asyncio.StreamWriter
is not closed (#107650)
This commit is contained in:
parent
5e2746d6e2
commit
41178e4199
3 changed files with 30 additions and 0 deletions
|
@ -5,6 +5,7 @@ __all__ = (
|
|||
import collections
|
||||
import socket
|
||||
import sys
|
||||
import warnings
|
||||
import weakref
|
||||
|
||||
if hasattr(socket, 'AF_UNIX'):
|
||||
|
@ -392,6 +393,11 @@ class StreamWriter:
|
|||
self._transport = new_transport
|
||||
protocol._replace_writer(self)
|
||||
|
||||
def __del__(self, warnings=warnings):
|
||||
if not self._transport.is_closing():
|
||||
self.close()
|
||||
warnings.warn(f"unclosed {self!r}", ResourceWarning)
|
||||
|
||||
|
||||
class StreamReader:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue