Skip to content

Commit

Permalink
Add a test for the bug fixed in commit e811959
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Sep 18, 2011
1 parent 662d8ac commit 5cf9890
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tornado/test/iostream_test.py
Expand Up @@ -137,3 +137,26 @@ def callback(data):
finally:
server.close()
client.close()

def test_delayed_close_callback(self):
# The scenario: Server closes the connection while there is a pending
# read that can be served out of buffered data. The client does not
# run the close_callback as soon as it detects the close, but rather
# defers it until after the buffered read has finished.
server, client = self.make_iostream_pair()
try:
client.set_close_callback(self.stop)
server.write(b("12"))
chunks = []
def callback1(data):
chunks.append(data)
client.read_bytes(1, callback2)
server.close()
def callback2(data):
chunks.append(data)
client.read_bytes(1, callback1)
self.wait() # stopped by close_callback
self.assertEqual(chunks, [b("1"), b("2")])
finally:
server.close()
client.close()

0 comments on commit 5cf9890

Please sign in to comment.