From b7d5d7c69f0ae5a2899d52de6557ef00f92bbb4a Mon Sep 17 00:00:00 2001 From: Aaron Chong Date: Sat, 4 Feb 2023 12:46:41 +0800 Subject: [PATCH] Fix the return order of AsyncHTMLSession.run --- README.rst | 4 +--- requests_html.py | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 793f80a..c207ff0 100644 --- a/README.rst +++ b/README.rst @@ -62,10 +62,8 @@ Try async and get some sites at the same time: ... print(result.html.url) ... https://www.python.org/ - https://www.google.com/ https://www.reddit.com/ - -Note that the order of the objects in the results list represents the order they were returned in, not the order that the coroutines are passed to the ``run`` method, which is shown in the example by the order being different. + https://www.google.com/ Grab a list of all links on the page, as–is (anchors excluded): diff --git a/requests_html.py b/requests_html.py index 48e7fb2..9a57f5c 100644 --- a/requests_html.py +++ b/requests_html.py @@ -839,5 +839,5 @@ def run(self, *coros): tasks = [ asyncio.ensure_future(coro()) for coro in coros ] - done, _ = self.loop.run_until_complete(asyncio.wait(tasks)) - return [t.result() for t in done] + _, _ = self.loop.run_until_complete(asyncio.wait(tasks)) + return [t.result() for t in tasks]