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