mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
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:
parent
dddc781998
commit
0ac3a0cd79
2 changed files with 22 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue