From c43996288e52a8f68728164f9284cf286d38543a Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 7 Jul 2013 13:38:08 -0400 Subject: [PATCH] Clear the write buffer when an IOStream is closed. Closes #828. --- tornado/iostream.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tornado/iostream.py b/tornado/iostream.py index 550e68da9..6a507a81d 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -274,6 +274,10 @@ class BaseIOStream(object): self._run_callback(cb) # Delete any unfinished callbacks to break up reference cycles. self._read_callback = self._write_callback = None + # Clear the buffers so they can be cleared immediately even + # if the IOStream object is kept alive by a reference cycle. + # TODO: Clear the read buffer too; it currently breaks some tests. + self._write_buffer = None def reading(self): """Returns true if we are currently reading from the stream.""" -- 2.47.2