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

Class Task

source code

object --+
         |
        Task

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 next(iterator) from a glib idle function.
source code
 
__repr__(self)
repr(x)
source code
 
__str__(self)
str(x)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, iterator, name)
(Constructor)

source code 

Call next(iterator) from a glib idle function. This function can yield Blocker() objects to suspend processing while waiting for events. name is used only for debugging.

Parameters:
  • name (str)
Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)