Package zeroinstall :: Package support :: Module tasks :: Class Task
[frames] | no frames]

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

Instance Methods
 
__init__(self, iterator, name)
Call iterator.next() from a glib idle function.
source code
 
__repr__(self) source code
 
__str__(self) source code
Method 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.