def stop(self):
        """
        Stop scheduling steps.  Errback the completion Deferreds of all
        iterators which have been added and forget about them.
        """
        self._stopped = True
        for taskObj in self._tasks:
            taskObj._completeWith(SchedulerStopped(),
                                  Failure(SchedulerStopped()))
        self._tasks = []
        if self._delayedCall is not None:
            self._delayedCall.cancel()
            self._delayedCall = None

        Stop scheduling steps.  Errback the completion Deferreds of all
        iterators which have been added and forget about them.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/task.py