if client is not None:
client.close()
+ @skipBefore35
+ @gen_test
+ def test_handle_stream_native_coroutine(self):
+ # handle_stream may be a native coroutine.
+
+ namespace = exec_test(globals(), locals(), """
+ class TestServer(TCPServer):
+ async def handle_stream(self, stream, address):
+ stream.write(b'data')
+ stream.close()
+ """)
+
+ sock, port = bind_unused_port()
+ server = namespace['TestServer']()
+ server.add_socket(sock)
+ client = IOStream(socket.socket())
+ yield client.connect(('localhost', port))
+ result = yield client.read_until_close()
+ self.assertEqual(result, b'data')
+ server.stop()
+ client.close()
++
+ def test_stop_twice(self):
+ sock, port = bind_unused_port()
+ server = TCPServer()
+ server.add_socket(sock)
+ server.stop()
+ server.stop()
+