From 51a3206600ff4c18f5368d0389157f6720126a4e Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Sun, 2 Aug 2015 16:47:28 -0400 Subject: Revert "tasks: Fix code style" This reverts commit 4851618b6b154272e79bdc1b5f63b4887e12d8e9 per Guido's comment: I don't like the refactoring. The original way (two nested if's) was IMO clearer about the side effect (of calling cancel()) that only happens if the first condition is true. The refactored version sweeps the side effect under the proverbial mat. --- asyncio/tasks.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/asyncio/tasks.py b/asyncio/tasks.py index 45c6d1b..9bfc1cf 100644 --- a/asyncio/tasks.py +++ b/asyncio/tasks.py @@ -249,8 +249,9 @@ class Task(futures.Future): result._blocking = False result.add_done_callback(self._wakeup) self._fut_waiter = result - if self._must_cancel and self._fut_waiter.cancel(): - self._must_cancel = False + if self._must_cancel: + if self._fut_waiter.cancel(): + self._must_cancel = False else: self._loop.call_soon( self._step, None, -- cgit v1.2.1