]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Disable preforking by default in HTTPServer.start().
authorBen Darnell <bdarnell@beaker.local>
Thu, 8 Jul 2010 22:52:44 +0000 (15:52 -0700)
committerBen Darnell <bdarnell@beaker.local>
Thu, 8 Jul 2010 22:52:44 +0000 (15:52 -0700)
This makes "server.listen(port)" and "server.bind(port);
server.start()" equivalent.

tornado/httpserver.py

index 2f0fa044dfda45411d7a9651db322ba65ae7134d..63131070fdf4d9b46fa102631159efcc0d169f4c 100644 (file)
@@ -150,22 +150,23 @@ class HTTPServer(object):
         self._socket.bind((address, port))
         self._socket.listen(128)
 
-    def start(self, num_processes=None):
+    def start(self, num_processes=1):
         """Starts this server in the IOLoop.
 
-        By default, we detect the number of cores available on this machine
-        and fork that number of child processes. If num_processes is given, we
-        fork that specific number of sub-processes.
+        By default, we run the server in this process and do not fork any
+        additional child process.
 
-        If num_processes is 1 or we detect only 1 CPU core, we run the server
-        in this process and do not fork any additional child process.
+        If num_processes is None or <= 0, we detect the number of cores
+        available on this machine and fork that number of child
+        processes. If num_processes is given and > 1, we fork that
+        specific number of sub-processes.
 
         Since we use processes and not threads, there is no shared memory
         between any server code.
         """
         assert not self._started
         self._started = True
-        if num_processes is None:
+        if num_processes is None or num_processes <= 0:
             # Use sysconf to detect the number of CPUs (cores)
             try:
                 num_processes = os.sysconf("SC_NPROCESSORS_CONF")