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
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 beawaited in async context, here it will staypendingforever.Call to
wait_until_finished()on executor does not help becauseget_responseis not a coroutine and returns a Promise. Async Promises are not handled bywait_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_promisewhich 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_promiselets 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