]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Return HTTPServer in Application.listen 1558/head
authorMaarten Breddels <maartenbreddels@gmail.com>
Mon, 19 Oct 2015 15:24:55 +0000 (17:24 +0200)
committerMaarten Breddels <maartenbreddels@gmail.com>
Mon, 19 Oct 2015 15:24:55 +0000 (17:24 +0200)
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

index 513af6f66e43c3e8718c0c106d04dae2666e20db..76788106962e444bd371226158365a6e50bd5515 100644 (file)
@@ -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.