In asyncio, does the event_loop still running after run_until_complete returned?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Apr 3 22:28:46 EDT 2018
On Mon, 02 Apr 2018 23:37:51 -0600, Ian Kelly wrote:
> If it helps to demystify things, here is a simplified version of what
> run_until_complete actually does:
>
> def run_until_complete(self, future):
> """Run until the Future is done.
>
> If the argument is a coroutine, it is wrapped in a Task.
>
> Return the Future's result, or raise its exception. """
Demystify, he says.
Future, he says. Coroutine. Task. What's self? What's tasks? What's
events? Enquiring minds want to know.
> future = tasks.ensure_future(future, loop=self)
> future.add_done_callback(self.stop)
> self.run_forever()
> future.remove_done_callback(self.stop)
> return future.result()
>
> def run_forever(self):
> """Run until stop() is called."""
o_O
That's obviously a different meaning to the word "forever" than I learnt
at school.
--
Steve
More information about the Python-list
mailing list