--- asyncio/tasks.py 2016-06-13 16:25:53.000000000 +0200 +++ asyncio/tasks.py 2016-06-15 10:10:51.637567952 +0200 @@ -208,14 +208,22 @@ terminates with a CancelledError exception (even if cancel() was not called). """ + print('Entered Task.cancel() for task {}'.format(self)) if self.done(): + print('Task is done(), refusing to cancel') return False if self._fut_waiter is not None: + print('Task is not done() and we have a _fut_waiter: Cancelling fut_waiter {}'.format(self._fut_waiter)) if self._fut_waiter.cancel(): + print('Great, _fut_waiter has agreed to be cancelled. We can now also return True') # Leave self._fut_waiter; it may be a Task that # catches and ignores the cancellation so we may have # to cancel it again later. return True + else: + print('_fut_waiter refused to be cancelled, now we have to cancel ourselves in the next _step') + else: + print('No _fut_waiter! Now we have to cancel ourselves in the next step') # It must be the case that self._step is already scheduled. self._must_cancel = True return True @@ -657,6 +665,7 @@ results[i] = res nfinished += 1 if nfinished == nchildren: + print('All children finished OK, setting _GatheringFuture results!') outer.set_result(results) for i, fut in enumerate(children):