Wait for all tasks to finish.
(self)
| 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.""" |
no test coverage detected