Package portage :: Package util :: Package _async :: Module TaskScheduler
[hide private]

Source Code for Module portage.util._async.TaskScheduler

 1  # Copyright 2012 Gentoo Foundation 
 2  # Distributed under the terms of the GNU General Public License v2 
 3   
 4  from .AsyncScheduler import AsyncScheduler 
 5   
6 -class TaskScheduler(AsyncScheduler):
7 8 """ 9 A simple way to handle scheduling of AbstractPollTask instances. Simply 10 pass a task iterator into the constructor and call start(). Use the 11 poll, wait, or addExitListener methods to be notified when all of the 12 tasks have completed. 13 """ 14
15 - def __init__(self, task_iter, **kwargs):
16 AsyncScheduler.__init__(self, **kwargs) 17 self._task_iter = task_iter
18
19 - def _next_task(self):
20 return next(self._task_iter)
21