+ This module provides the multiprocessing implementation used by Sphinx. You
+ should be aware of the fact that although being similar in API to
+ :mod:`multiprocessing` the implementation may not be based on it.
+ :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+from itertools import imap
+GreenPool = MultiProcessingPool = None
+ from eventlet import GreenPool
+ from multiprocessing import Pool as MultiProcessingPool
+ from multiprocessing import cpu_count as _cpu_count
+ raise NotImplementedError()
+# try to guess the number of cpus on this system, default to 2 as most modern
+# systems should have 2 by now
+CPU_COUNT_SYSCONF_NAME = 'SC_NPROCESSORS_ONLN'
+ CPU_COUNT = _cpu_count()
+ if CPU_COUNT_SYSCONF_NAME in os.sysconf_names:
+ CPU_COUNT = os.sysconf(CPU_COUNT_SYSCONF_NAME)
+ """A dummy pool object which implements the API we need."""
+ def __init__(self, processes=0):
+ self.processes = processes
+ def imap(self, func, iterable):
+ return imap(func, iterable)
+ """Returns a pool object using the given number of `processes`."""
+ implementations = [GreenPool, MultiProcessingPool, DummyPool]
+ for implementation in implementations:
+ if implementation is not None:
+ return implementation(processes)