From: Ben Darnell Date: Thu, 8 Jul 2010 22:52:44 +0000 (-0700) Subject: Disable preforking by default in HTTPServer.start(). X-Git-Tag: v1.0.0~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e98735bf4b35688aadeaffbfe1fc6ad636ebc318;p=thirdparty%2Ftornado.git Disable preforking by default in HTTPServer.start(). This makes "server.listen(port)" and "server.bind(port); server.start()" equivalent. --- diff --git a/tornado/httpserver.py b/tornado/httpserver.py index 2f0fa044d..63131070f 100644 --- a/tornado/httpserver.py +++ b/tornado/httpserver.py @@ -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")