MCPcopy
hub / github.com/InternLM/lmdeploy / wait_tasks

Method wait_tasks

lmdeploy/pytorch/engine/engine_loop.py:566–585  ·  view source on GitHub ↗

Wait for all tasks to finish.

(self)

Source from the content-addressed store, hash-verified

564 task.add_done_callback(self.tasks.discard)
565
566 async def wait_tasks(self):
567 """Wait for all tasks to finish."""
568 if not self.tasks:
569 return
570
571 # copy the tasks so callback of tasks would not update it
572 tasks = self.tasks.copy()
573 try:
574 await wait_for_async_tasks(tasks)
575 except asyncio.CancelledError:
576 logger.info('EngineLoop wait_tasks cancelled.')
577 raise
578 except BaseException:
579 logger.error('EngineLoop wait_tasks failed.')
580 raise
581 finally:
582 logger.debug('EngineLoop wait_tasks cleanup.')
583 # Make sure task finished/cancelled here.
584 # Error might happen if executor release before executor wait_tasks finish.
585 await cancel_async_tasks(tasks)
586
587 def stop(self):
588 """Stop all loops."""

Callers 1

startMethod · 0.45

Calls 3

wait_for_async_tasksFunction · 0.90
cancel_async_tasksFunction · 0.90
copyMethod · 0.45

Tested by

no test coverage detected