There is some strange behavior of the http_server.start method. It
always get 1 process as a parametr
and only then it's calling with number of process equal to CPUs number
if for example change start method to this:
num_processes = 2
if(not self._started):
self._started = True
if num_processes is None:
# Use sysconf to detect the number of CPUs (cores)
try:
num_processes = os.sysconf("SC_NPROCESSORS_CONF")
except ValueError:
logging.error("Could not get num processors from sysconf; "
"running with one process")
num_processes = 2
if num_processes > 1 and ioloop.IOLoop.initialized():
logging.error("Cannot run in multiple processes: IOLoop instance
"
"has already been initialized. You cannot call "
"IOLoop.instance() before calling start()")
num_processes = 1
if num_processes > 1:
logging.info("Pre-forking %d server processes", num_processes)
for i in range(num_processes):
print i
if os.fork() == 0:
ioloop.IOLoop.instance().add_handler(
self._socket.fileno(), self._handle_events,
ioloop.IOLoop.READ)
return
os.waitpid(-1, 0)
else:
io_loop = self.io_loop or ioloop.IOLoop.instance()
io_loop.add_handler(self._socket.fileno(), self._handle_events,
ioloop.IOLoop.READ)
It would fork 2 process. But if remove hard encoded number of process
it will always create only singe process.