Commit 47643cca authored by Jason Madden's avatar Jason Madden

Pre-allocate the (biggec) data before we start taking timing measurements, and...

Pre-allocate the (biggec) data before we start taking timing measurements, and be sure to close the socket when done.
parent ac7911c7
......@@ -146,20 +146,22 @@ class TestTCP(greentest.TestCase):
if sys.platform != 'win32':
def test_sendall_timeout(self):
data_sent = b'h' * 2000000
client_sock = []
acceptor = Thread(target=lambda: client_sock.append(self.listener.accept()))
client = self.create_connection()
time.sleep(0.1)
assert client_sock
client.settimeout(0.1)
data_sent = b'h' * 1000000
start = time.time()
self.assertRaises(self.TIMEOUT_ERROR, client.sendall, data_sent)
took = time.time() - start
assert 0.1 - 0.01 <= took <= 0.1 + 0.1, took
acceptor.join()
client.close()
client_sock[0][0].close()
try:
self.assertRaises(self.TIMEOUT_ERROR, client.sendall, data_sent)
took = time.time() - start
assert 0.1 - 0.01 <= took <= 0.1 + 0.1, took
finally:
acceptor.join()
client.close()
client_sock[0][0].close()
def test_makefile(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment