示例#1
0
 def __init__(self, timeout_spawn):
     """
     @param timeout_spawn    Default timeout in secs for the RUNNING event.
     """
     self._timeout_spawn = timeout_spawn
     self._pd_client = ProcessDispatcherServiceClient()
     self._agent_launcher = AgentLauncher(self._pd_client)
示例#2
0
    def _get_dsa_client(self, instrument_device, dsa_instance):
        """
        Launch the agent and return a client
        """
        fake_process = FakeProcess()
        fake_process.container = self.container

        clients = DataAcquisitionManagementServiceDependentClients(
            fake_process)
        config_builder = ExternalDatasetAgentConfigurationBuilder(clients)

        try:
            config_builder.set_agent_instance_object(dsa_instance)
            self.agent_config = config_builder.prepare()
        except Exception as e:
            log.error('failed to launch: %s', e, exc_info=True)
            raise ServerError('failed to launch')

        self._dsa_pid = self.dams.start_external_dataset_agent_instance(
            dsa_instance._id)
        log.debug("_get_dsa_client CFG")
        return ResourceAgentClient(instrument_device._id,
                                   process=FakeProcess())

        dispatcher = ProcessDispatcherServiceClient()
        launcher = AgentLauncher(dispatcher)

        log.debug("Launching agent process!")

        self._dsa_pid = launcher.launch(
            self.agent_config,
            config_builder._get_process_definition()._id)
        if not self._dsa_pid:
            raise ServerError(
                "Launched external dataset agent instance but no process_id")
        config_builder.record_launch_parameters(self.agent_config)

        launcher.await_launch(10.0)
        return ResourceAgentClient(instrument_device._id,
                                   process=FakeProcess())