code: def switch_service(self, new_service=None):
          
          if new_service:
              self._service_factory = new_service
          with self.__lock:
              # Terminate existing service if necessary
              if self._service is not None:
                  self._terminate_service()
  
              # Find service class if necessary
              if isinstance(self._service_factory, basestring):
                  self._service_factory = workflows.services.lookup(self._service_factory)
              if not self._service_factory:
                  return False
  
              # Set up new service object
              service_instance = self._service_factory(
                  environment=self._service_environment
              )
  
              # Set up pipes and connect service object
              svc_commands, self._pipe_commands = multiprocessing.Pipe(False)
              self._pipe_service, svc_tofrontend = multiprocessing.Pipe(False)
              service_instance.connect(commands=svc_commands, frontend=svc_tofrontend)
  
              # Set up transport layer for new service
              service_instance.transport = self._transport_factory()
  
              # Start new service in a separate process
              self._service = multiprocessing.Process(
                  target=service_instance.start,
                  args=(),
                  kwargs={"verbose_log": self._verbose_service},
              )
              self._service_name = service_instance.get_name()
              self._service_class_name = service_instance.__class__.__name__
              self._service.daemon = True
              self._service.name = "workflows-service"
              self._service.start()
              self._service_starttime = time.time()
  
              # Starting the process copies all file descriptors.
              # At this point (and no sooner!) the passed pipe objects must be closed
              # in this process here.
              svc_commands.close()
              svc_tofrontend.close()
          self.log.info("Started service: %s", self._service_name)
          return True
docs: Start a new service in a subprocess.
          :param new_service: Either a service name or a service class. If not set,
                              start up a new instance of the previous class
          :return: True on success, False on failure.