@@ -542,17 +542,17 @@ def ensure_future(coro_or_future, *, loop=None):
|
542 | 542 | |
543 | 543 | If the argument is a Future, it is returned directly. |
544 | 544 | """ |
545 | | -if futures.isfuture(coro_or_future): |
546 | | -if loop is not None and loop is not futures._get_loop(coro_or_future): |
547 | | -raise ValueError('loop argument must agree with Future') |
548 | | -return coro_or_future |
549 | | -elif coroutines.iscoroutine(coro_or_future): |
| 545 | +if coroutines.iscoroutine(coro_or_future): |
550 | 546 | if loop is None: |
551 | 547 | loop = events.get_event_loop() |
552 | 548 | task = loop.create_task(coro_or_future) |
553 | 549 | if task._source_traceback: |
554 | 550 | del task._source_traceback[-1] |
555 | 551 | return task |
| 552 | +elif futures.isfuture(coro_or_future): |
| 553 | +if loop is not None and loop is not futures._get_loop(coro_or_future): |
| 554 | +raise ValueError('loop argument must agree with Future') |
| 555 | +return coro_or_future |
556 | 556 | elif inspect.isawaitable(coro_or_future): |
557 | 557 | return ensure_future(_wrap_awaitable(coro_or_future), loop=loop) |
558 | 558 | else: |
|