Example #1
0
    async def connect(self, address: str, flags: Set[str] = None) -> None:
        assert self.__stub is None
        self.__stub = ipc.Stub(self.event_loop, address)

        request = core.StartSessionRequest(
            callback_address=self.__cb_endpoint_address, flags=flags)
        await self.__stub.connect(request)
    async def create_process(self):
        proc = await self.mgr.start_subprocess(
            'test-urid-mapper',
            'noisicaa.lv2.urid_mapper_process.URIDMapperSubprocess')

        stub = ipc.Stub(self.loop, proc.address)
        await stub.connect(
            core.StartSessionRequest(callback_address=self.cb_endpoint_address)
        )
        return proc, stub
    async def create_process(self, *, inline):
        if inline:
            proc = await self.process_manager.start_inline_process(
                name='test-plugin-host',
                entry='noisicaa.audioproc.engine.plugin_host_process.PluginHostProcess')
        else:
            proc = await self.process_manager.start_subprocess(
                'test-plugin-host',
                'noisicaa.audioproc.engine.plugin_host_process.PluginHostSubprocess')

        stub = ipc.Stub(self.loop, proc.address)
        await stub.connect()
        return proc, stub
Example #4
0
    async def __shutdown_process(self, address):
        if address is None:
            return

        p = urllib.parse.urlparse(address)
        control_address = 'ipc://control@%s' % p.path

        try:
            stub = ipc.Stub(self.loop, control_address)
            try:
                await stub.connect()
                await stub.call('SHUTDOWN')
            finally:
                await stub.close()

        except ipc.Error:
            logger.info("Failed to send SHUTDOWN to %s", address)
Example #5
0
    async def setup(self) -> None:
        logger.info("Setting up player instance %s..", self.id)

        if self.callback_address is not None:
            logger.info("Connecting to client callback server %s..",
                        self.callback_address)
            self.callback_stub = ipc.Stub(self.event_loop,
                                          self.callback_address)
            await self.callback_stub.connect()

        self.__listeners[
            'pipeline_mutations'] = self.project.pipeline_mutation.add(
                self.handle_pipeline_mutation)

        logger.info("Populating realm with project state...")
        for mutation in self.project.get_add_mutations():
            await self.publish_pipeline_mutation(mutation)

        await self.audioproc_client.update_project_properties(
            self.realm,
            audioproc.ProjectProperties(
                bpm=self.project.bpm,
                duration=self.project.duration.to_proto()))

        messages = audioproc.ProcessorMessageList()
        for node in self.project.nodes:
            messages.messages.extend(self.add_node(node))
        await self.audioproc_client.send_node_messages(self.realm, messages)

        await self.set_session_values(self.session_values.values())
        self.__listeners[
            'session_values'] = self.session_values.values_changed.add(
                self.set_session_values)

        self.__listeners['project:nodes'] = self.project.nodes_changed.add(
            self.__on_project_nodes_changed)
        self.__listeners['project:bpm'] = self.project.bpm_changed.add(
            self.__on_project_bpm_changed)
        self.__listeners[
            'project:duration'] = self.project.duration_changed.add(
                self.__on_project_duration_changed)

        logger.info("Player instance %s setup complete.", self.id)
Example #6
0
    async def setup_testcase(self):
        self.process_manager = core.ProcessManager(event_loop=self.loop,
                                                   tmp_dir=TEST_OPTS.TMP_DIR)
        await self.process_manager.setup()

        async def shutdown_process(request, response):
            await self.process_manager.shutdown_process(request.address)

        self.process_manager.server['main'].add_handler(
            'SHUTDOWN_PROCESS', shutdown_process,
            editor_main_pb2.ShutdownProcessRequest,
            empty_message_pb2.EmptyMessage)

        self.process_manager_client = ipc.Stub(
            self.loop, self.process_manager.server.address)
        await self.process_manager_client.connect()

        self.__node_db_lock = asyncio.Lock(loop=self.loop)
        self.__instrument_db_lock = asyncio.Lock(loop=self.loop)
        self.__urid_mapper_lock = asyncio.Lock(loop=self.loop)
Example #7
0
    async def connect(self, address: str) -> None:
        assert self.__stub is None

        self.__stub = ipc.Stub(self.__event_loop, address)
        await self.__stub.connect()
Example #8
0
 async def __setup_callback_stub(self) -> None:
     self.__callback = ipc.Stub(self.__event_loop, self.__callback_address)
     await self.__callback.connect()