From b5d6734893d3c8bcf1a4516bf1f98e2415a62a15 Mon Sep 17 00:00:00 2001 From: Maarten Breddels Date: Mon, 19 Oct 2015 17:24:55 +0200 Subject: [PATCH] Return HTTPServer in Application.listen For unittesting I start and stop the server in setUp and tearDown. If I use Application.listen I don't have a reference to the HTTPServer and cannot close the socket. Binding it to the same address the next time will result in a address in use error. If the server is returned, calling close on it will allow the address/port to be reused. --- tornado/web.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tornado/web.py b/tornado/web.py index 513af6f66..767881069 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -1810,6 +1810,7 @@ class Application(httputil.HTTPServerConnectionDelegate): from tornado.httpserver import HTTPServer server = HTTPServer(self, **kwargs) server.listen(port, address) + return server def add_handlers(self, host_pattern, host_handlers): """Appends the given handlers to our handler list. -- 2.47.2