MCPcopy Index your code
hub / github.com/python/cpython / run_until_complete

Method run_until_complete

Lib/asyncio/base_events.py:688–724  ·  view source on GitHub ↗

Run until the Future is done. If the argument is a coroutine, it is wrapped in a Task. WARNING: It would be disastrous to call run_until_complete() with the same coroutine twice -- it would wrap it in two different Tasks and that can't be good. Return the F

(self, future)

Source from the content-addressed store, hash-verified

686 self._run_forever_cleanup()
687
688 def run_until_complete(self, future):
689 """Run until the Future is done.
690
691 If the argument is a coroutine, it is wrapped in a Task.
692
693 WARNING: It would be disastrous to call run_until_complete()
694 with the same coroutine twice -- it would wrap it in two
695 different Tasks and that can't be good.
696
697 Return the Future's result, or raise its exception.
698 """
699 self._check_closed()
700 self._check_running()
701
702 new_task = not futures.isfuture(future)
703 future = tasks.ensure_future(future, loop=self)
704 if new_task:
705 # An exception is raised if the future didn't complete, so there
706 # is no need to log the "destroy pending task" message
707 future._log_destroy_pending = False
708
709 future.add_done_callback(_run_until_complete_cb)
710 try:
711 self.run_forever()
712 except:
713 if new_task and future.done() and not future.cancelled():
714 # The coroutine raised a BaseException. Consume the exception
715 # to not log a warning, the caller doesn't have access to the
716 # local task.
717 future.exception()
718 raise
719 finally:
720 future.remove_done_callback(_run_until_complete_cb)
721 if not future.done():
722 raise RuntimeError('Event loop stopped before Future completed.')
723
724 return future.result()
725
726 def stop(self):
727 """Stop running the event loop.

Callers

nothing calls this directly

Calls 9

_check_closedMethod · 0.95
_check_runningMethod · 0.95
run_foreverMethod · 0.95
add_done_callbackMethod · 0.45
doneMethod · 0.45
cancelledMethod · 0.45
exceptionMethod · 0.45
remove_done_callbackMethod · 0.45
resultMethod · 0.45

Tested by

no test coverage detected