summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/streams.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/asyncio/streams.py')
-rw-r--r--Lib/asyncio/streams.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py
index f82b10c..ffb48b9 100644
--- a/Lib/asyncio/streams.py
+++ b/Lib/asyncio/streams.py
@@ -406,9 +406,11 @@ class StreamWriter:
def __del__(self, warnings=warnings):
if not self._transport.is_closing():
- self.close()
- warnings.warn(f"unclosed {self!r}", ResourceWarning)
-
+ if self._loop.is_closed():
+ warnings.warn("loop is closed", ResourceWarning)
+ else:
+ self.close()
+ warnings.warn(f"unclosed {self!r}", ResourceWarning)
class StreamReader: