2 import multiprocessing.pool
3 import multiprocessing.util
as util
5 from .queue
import SimpleQueue
8 def clean_worker(*args, **kwargs):
10 multiprocessing.pool.worker(*args, **kwargs)
18 """Pool implementation which uses our version of SimpleQueue. 19 This lets us pass tensors in shared memory across processes instead of 20 serializing the underlying data.""" 22 def _setup_queues(self):
28 def _repopulate_pool(self):
29 """Bring the number of pool processes up to the specified number, 30 for use after reaping workers which have exited. 32 for i
in range(self._processes - len(self._pool)):
36 self._initargs, self._maxtasksperchild)
37 if hasattr(self,
'_wrap_exception'):
38 args += (self._wrap_exception,)
39 w = self.Process(target=clean_worker, args=args)
41 w.name = w.name.replace(
'Process',
'PoolWorker')
44 util.debug(
'added worker')