]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Check self.closed() in the inner read loop of IOStream.
authorBen Darnell <ben@bendarnell.com>
Sun, 7 Oct 2012 04:06:52 +0000 (21:06 -0700)
committerBen Darnell <ben@bendarnell.com>
Sun, 7 Oct 2012 04:06:52 +0000 (21:06 -0700)
This was causing error logs in the keepalive tests (but only on epoll)

tornado/iostream.py

index 23457d9f035e9cfca14af5cd3605fbb914c4c333..34fa9ed374dc9883a1187eec5d87fe0baab944d7 100644 (file)
@@ -330,7 +330,7 @@ class BaseIOStream(object):
                 # clause below (which calls `close` and does need to
                 # trigger the callback)
                 self._pending_callbacks += 1
-                while True:
+                while not self.closed():
                     # Read from the socket until we get EWOULDBLOCK or equivalent.
                     # SSL sockets do some internal buffering, and if the data is
                     # sitting in the SSL object's buffer select() and friends
@@ -367,10 +367,9 @@ class BaseIOStream(object):
         try:
             # See comments in _handle_read about incrementing _pending_callbacks
             self._pending_callbacks += 1
-            while True:
+            while not self.closed():
                 if self._read_to_buffer() == 0:
                     break
-                self._check_closed()
         finally:
             self._pending_callbacks -= 1
         if self._read_from_buffer():