def _serve(self, nodes=None): #XXX: should be STATE method; use id """Create a new server if one isn't already initialized""" if nodes is None: nodes = self.__nodes _pool = __STATE.get(self._id, None) if not _pool or nodes != _pool.__nodes: self._clear() _pool = _ThreadPool(nodes) _pool.__nodes = nodes __STATE[self._id] = _pool return _pool
def restart(self, force=False): "restart a closed pool" _pool = __STATE.get(self._id, None) if _pool and self.__nodes == _pool.__nodes: RUN = 0 if not force: assert _pool._state != RUN # essentially, 'clear' and 'serve' self._clear() _pool = _ThreadPool(self.__nodes) _pool.__nodes = self.__nodes __STATE[self._id] = _pool return _pool