Class Task
source code
Create a new Task when you have some long running function to run in
the background, but which needs to do work in 'chunks'. Example:
>>> from zeroinstall import tasks
>>> def my_task(start):
for x in range(start, start + 5):
print "x =", x
yield None
>>> tasks.Task(my_task(0))
>>> tasks.Task(my_task(10))
>>> mainloop()
Yielding None gives up control of the processor to another Task,
causing the sequence printed to be interleaved. You can also yield a
Blocker (or a list of Blockers) if you want to wait for some particular
event before resuming (see the Blocker class for details).
__init__(self,
iterator,
name)
(Constructor)
| source code
|
Call iterator.next() from a glib idle function. This function can
yield Blocker() objects to suspend processing while waiting for events.
name is used only for debugging.
|