aboutsummaryrefslogtreecommitdiff
blob: 35b3875a4218cb7ebfda9f8aaf0e2d254533347f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Copyright 2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

from .AsyncScheduler import AsyncScheduler

class TaskScheduler(AsyncScheduler):

	"""
	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)