def __init__(self, connection_info): if connection_info.port is None or connection_info.ip is None: connection_info.ip = utils.get_my_IP() connection_info.port = config.get_service_port() super(ServiceHandler_Local, self).__init__(connection_info) self._proc = None
def spawn_services(self): """ Spawn remote services via some bootstrap method. """ assert not self.service_handles, "ERROR: services already running; " \ "shut them down before spawning again" if self._service_infos is None: self._service_infos = [] my_ip = utils.get_my_IP() start_port = config.get_service_port() for port in range(start_port, start_port + self.DEFAULT_INSTANCE_COUNT): ci = bootstrap.ConnectionInfo(my_ip, port, None) self._service_infos.append(ci) bootstrap.ServiceHandleArray.REMOTE_CONNECTION_CLASS = \ self._service_handler_class self.service_handles = \ bootstrap.ServiceHandleArray(self._service_infos) logger.debug("Attempting to start services of type %s", self.service_name) self.service_handles.start_cmd(self.service_name) logger.debug("Signaled services should start")
def on_connect(self, conn): super(WalkExecutorService, self).on_connect(conn) # Maps worker_id->WalkRunner instance self._runners = {} self._service_port = config.get_service_port() self.verbose_file_path = None self.trace_file_path = None self._next_walk_id = 0
def start_service(service_class, port=None): """ Start an rpyc service given by the provided class. Port can be overridden. :param rpyc.Service service_class: a child class of :class:`rpyc.Service`. :param int port: the port the service should listen for requests on. If it isn't provided by the caller, we we get a value from :class:`combtest.config` :return: a handle to the resulting :class:`ThreadedServer`. """ # rpyc uses logging, and we want to dump its logging somehow on errors _ensure_stderr_handler() if port is None: port = get_service_port() else: set_service_port(port) from rpyc.utils.server import ThreadPoolServer t = ThreadPoolServer(service_class, port=port) t.start() return t