summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2016-10-09 16:20:44 (GMT)
committerYury Selivanov <yury@magic.io>2016-10-09 16:20:44 (GMT)
commit917c1c3ee1b4cbe7a7a78ffde053fb5628eee486 (patch)
tree6ef83f2beb72efd8e68ab67a996eb11b54492aa0 /Lib/asyncio
parent88e8aca78d71fa917a057e8d60b24f4a364d3248 (diff)
parent4145c8380699f7af14ae15179e01652e25f0d102 (diff)
downloadcpython-917c1c3ee1b4cbe7a7a78ffde053fb5628eee486.zip
cpython-917c1c3ee1b4cbe7a7a78ffde053fb5628eee486.tar.gz
cpython-917c1c3ee1b4cbe7a7a78ffde053fb5628eee486.tar.bz2
Merge 3.5 (issue #27972)
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/tasks.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index f735b44..14949d1 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -241,7 +241,7 @@ class Task(futures.Future):
result = coro.throw(exc)
except StopIteration as exc:
self.set_result(exc.value)
- except futures.CancelledError as exc:
+ except futures.CancelledError:
super().cancel() # I.e., Future.cancel(self).
except Exception as exc:
self.set_exception(exc)
@@ -259,12 +259,19 @@ class Task(futures.Future):
'Task {!r} got Future {!r} attached to a '
'different loop'.format(self, result)))
elif blocking:
- result._asyncio_future_blocking = False
- result.add_done_callback(self._wakeup)
- self._fut_waiter = result
- if self._must_cancel:
- if self._fut_waiter.cancel():
- self._must_cancel = False
+ if result is self:
+ self._loop.call_soon(
+ self._step,
+ RuntimeError(
+ 'Task cannot await on itself: {!r}'.format(
+ self)))
+ else:
+ result._asyncio_future_blocking = False
+ result.add_done_callback(self._wakeup)
+ self._fut_waiter = result
+ if self._must_cancel:
+ if self._fut_waiter.cancel():
+ self._must_cancel = False
else:
self._loop.call_soon(
self._step,