From: Maarten Breddels Date: Mon, 19 Oct 2015 15:24:55 +0000 (+0200) Subject: Return HTTPServer in Application.listen X-Git-Tag: v4.3.0b2~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5d6734893d3c8bcf1a4516bf1f98e2415a62a15;p=thirdparty%2Ftornado.git 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. --- 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.