'Get a L{defer.Deferred} notification of when this task is complete.
@return: a L{defer.Deferred} that fires with the C{iterator} that this
L{CooperativeTask} was created with when the iterator has been
exhausted (i.e. its C{next} method has raised C{StopIteration}), or
fails with the exception raised by C{next} if it raises some other
exception.
@rtype: L{defer.Deferred}'

def whenDone(self):

    d = defer.Deferred()
    if (self._completionState is None):
        self._deferreds.append(d)
    else:
        d.callback(self._completionResult)
    return d
