def worker(self):
        i = 0
        while True:
            i += 1
            if self._doDeferNext:
                self._doDeferNext = False
                d = defer.Deferred()
                self.work.append(d)
                yield d
            elif self._doStopNext:
                return
            elif self._doDieNext:
                raise UnhandledException()
            else:
                self.work.append(i)
                yield i
This is a sample generator which yields Deferreds when we are testing
dataset/ETHPy150Open twisted/twisted/twisted/test/test_cooperator.py/RunStateTests.worker