From: Ben Darnell Date: Sun, 4 Aug 2013 22:08:01 +0000 (-0400) Subject: Clear the IOStream buffers on close even when there is no close callback. X-Git-Tag: v3.2.0b1~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2e23670818483f8d7d31a96aa31d94402db2859;p=thirdparty%2Ftornado.git Clear the IOStream buffers on close even when there is no close callback. Closes #828. (again) --- diff --git a/tornado/iostream.py b/tornado/iostream.py index cd97f9d30..ecd10fb63 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -265,13 +265,13 @@ class BaseIOStream(object): self._maybe_run_close_callback() def _maybe_run_close_callback(self): - if (self.closed() and self._close_callback and - self._pending_callbacks == 0): - # if there are pending callbacks, don't run the close callback - # until they're done (see _maybe_add_error_handler) - cb = self._close_callback - self._close_callback = None - self._run_callback(cb) + # If there are pending callbacks, don't run the close callback + # until they're done (see _maybe_add_error_handler) + if self.closed() and self._pending_callbacks == 0: + if self._close_callback is not None: + cb = self._close_callback + self._close_callback = None + 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