Skip to content

broken support for AsyncioExecutor #32

Closed
@blazewicz

Description

@blazewicz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions