异步IO任务(apache beam管道)在python中同步运行

异步IO任务(apache beam管道)在python中同步运行,python,python-asyncio,apache-beam,Python,Python Asyncio,Apache Beam,我有下一个代码: def runner(self): logger.info('Start run for parallel jobs...') loop = asyncio.get_event_loop() tasks = [] for p in self.pipes: tasks.append(loop.create_task(catch_async_exceptions(

我有下一个代码:

def runner(self):
        logger.info('Start run for parallel jobs...')
        loop = asyncio.get_event_loop()
        tasks = []
        for p in self.pipes:
            tasks.append(loop.create_task(catch_async_exceptions(
                self._start_runner(p)
            )))
        loop.run_until_complete(asyncio.wait(tasks))
        loop.close()

    async def _start_runner(self, pipe):
        result = pipe.run()
        result.wait_until_finish()
        logger.info(f'Runner finished with success. Exit')
此代码:

result = pipe.launch()
result.wait_until_finish()

这是一项很长的任务,在此部分中,程序等待管道完成。我有几根管子,我想把它们并联起来。但是使用这段代码,asyncio仍然一个接一个地启动管道,等待一个管道完成,然后启动另一个管道。我是否仍然可以并行运行它们,并使其在自己的“任务”中“等待”直到“完成”,以便能够捕获异常而不冻结其他任务?或者使用asyncio,我不需要等待管道完成?这里的管道是ApacheBeam管道。

是否是
等待\u直到完成
异步?不幸的是,您的
\u start\u runner
函数没有等待任何东西,因此它只是名义上的异步。您需要切换到实际支持asyncio的管道库。