asyncio: Make Tasks check if Futures are attached to the same event loop

See https://github.com/python/asyncio/pull/303 for details
This commit is contained in:
Yury Selivanov 2015-12-11 11:33:59 -05:00
parent dddc781998
commit 0ac3a0cd79
2 changed files with 22 additions and 1 deletions

View file

@ -251,7 +251,13 @@ class Task(futures.Future):
else:
if isinstance(result, futures.Future):
# Yielded Future must come from Future.__iter__().
if result._blocking:
if result._loop is not self._loop:
self._loop.call_soon(
self._step,
RuntimeError(
'Task {!r} got Future {!r} attached to a '
'different loop'.format(self, result)))
elif result._blocking:
result._blocking = False
result.add_done_callback(self._wakeup)
self._fut_waiter = result