]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Allow the caller to specify the listen() backlog in HTTPServer.bind.
authorBen Darnell <ben@bendarnell.com>
Sat, 2 Jul 2011 21:36:37 +0000 (14:36 -0700)
committerBen Darnell <ben@bendarnell.com>
Sat, 2 Jul 2011 21:36:37 +0000 (14:36 -0700)
tornado/httpserver.py

index 1fd74c35ca14b3399725f92783e8b5b4328ce695..c36e3bf2bf7ddad80a2518a4929d914fd31d9bb3 100644 (file)
@@ -164,7 +164,7 @@ class HTTPServer(object):
         self.bind(port, address)
         self.start(1)
 
-    def bind(self, port, address=None, family=socket.AF_UNSPEC):
+    def bind(self, port, address=None, family=socket.AF_UNSPEC, backlog=128):
         """Binds this server to the given port on the given address.
 
         To start the server, call start(). If you want to run this server
@@ -178,6 +178,9 @@ class HTTPServer(object):
         or socket.AF_INET6 to restrict to ipv4 or ipv6 addresses, otherwise
         both will be used if available.
 
+        The ``backlog`` argument has the same meaning as for 
+        ``socket.listen()``.
+
         This method may be called multiple times prior to start() to listen
         on multiple ports or interfaces.
         """
@@ -211,7 +214,7 @@ class HTTPServer(object):
                     sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
             sock.setblocking(0)
             sock.bind(sockaddr)
-            sock.listen(128)
+            sock.listen(backlog)
             self._sockets[sock.fileno()] = sock
             if self._started:
                 self.io_loop.add_handler(sock.fileno(), self._handle_events,