Skip to content

broken support for AsyncioExecutor #32

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

Closed
blazewicz opened this issue Dec 21, 2019 · 1 comment · Fixed by #33
Closed

broken support for AsyncioExecutor #32

blazewicz opened this issue Dec 21, 2019 · 1 comment · Fixed by #33

Comments

@blazewicz
Copy link
Contributor

The #13 PR introduced executors into request processing for batched queries. It also broken support for use of AsyncioExecutor from within asyncio context.

When using AsyncioExecutor this line blocks forever:

https://github.com/graphql-python/graphql-server-core/blob/427cccb00ae41fb88e8fcaf89aa64f5edb855394/graphql_server/__init__.py#L137

The get() method is called on Promise that must be awaited in async context, here it will stay pending forever.

Call to wait_until_finished() on executor does not help because get_response is not a coroutine and returns a Promise. Async Promises are not handled by wait_until_finished() method of AsyncioExecutor (code). Even if it was, AsyncioExecutor.wait_until_finished() cannot run from within asyncio context and would fail for any asyncio-based application like aiohttp server.

related issue: graphql-python/graphql-core#67

Fix to the above issue introduces a flag return_promise which is just what we need to handle response in async context.

implementatio details:

graphql-python/graphql-core@b4758b1
graphql-python/graphql-core@895b324
graphql-python/graphql-core@cea224a

This fragment of graphql-core test show hows its intended to be used in asyncio context:

https://github.com/graphql-python/graphql-core/blob/a600f7c662e7a6db7d6b56e7c67bf43925b6b23d/tests_py35/core_execution/test_asyncio_executor.py#L65-L75

The return_promise lets the main application handle waiting for executors to finish its task, so graphql-server-core should respect that.

I found this issue in my aiohttp application (using graphql-python/aiohttp-graphql), all queries would block forever. I had to restrict this package version to <=1.1.1

@Cito
Copy link
Member

Cito commented Jan 23, 2020

This should now be fixed in 1.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants