Permalink
Browse files

Check self.closed() in the inner read loop of IOStream.

This was causing error logs in the keepalive tests (but only on epoll)
  • Loading branch information...
1 parent 50e0a97 commit 2d7520e76858191acc2adf095279ffdbcea0d1cf @bdarnell bdarnell committed Oct 7, 2012
Showing with 2 additions and 3 deletions.
  1. +2 −3 tornado/iostream.py
View
@@ -330,7 +330,7 @@ def _handle_read(self):
# 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 @@ def _try_inline_read(self):
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():

0 comments on commit 2d7520e

Please sign in to comment.