Методы профилирования линии, которые находятся внутри asyncio.gather () - PullRequest
0 голосов
/ 09 апреля 2020

У меня есть следующий код (пример из-за NDA)

class Executor:

    @profile
    async def run(self):
        result = await __run_and_validate()

    async def __run_and_validate(self):
        # other async function awaited here

Звонящий:

class ExecutorCaller:

    def __init__(self, loop=None):
        self._loop = loop or asyncio.get_event_loop

    @profile
    def run(self):
        tasks = []
        for i in range(10)
            executor = Executor()
            tasks.append(executor.run())

        results = self._loop.run_until_complete(await asyncio.gather(**tasks))

Запуск моей программы с kerprof -l Я вижу, что results = self._loop.run_until_complete(await asyncio.gather(**tasks)) занимает 16se c, но функция Executor.run занимает 0,2 секунды.

Как я могу выстроить профиль кода внутри задач по их фактическому времени выполнения?

...