Skip to content

Async executor "wait for pending futures" #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions graphql/execution/executors/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ def __init__(self, loop=None):

def wait_until_finished(self):
# if there are futures to wait for
if self.futures:
while self.futures:
# wait for the futures to finish
self.loop.run_until_complete(wait(self.futures))
futures = self.futures
self.futures = []
self.loop.run_until_complete(wait(futures))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here Instead of calling run_until_complete it could call a friendlier method to those who already have loop running ..

async def wait_until_finished(self):
         # if there are futures to wait for
       if self.futures:
       while self.futures:
           # wait for the futures to finish
           futures = self.futures
           self.futures = []
           self.loop.create_task(futures)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I think this code here have some issues
We should give the timeout for the run_until_complete one right?

Or if the task not finished or something else wrong, the task just hang there, the self.futures will always be True, and stuck here.
Then the request is always pending.


def execute(self, fn, *args, **kwargs):
result = fn(*args, **kwargs)
Expand Down