-
-
Notifications
You must be signed in to change notification settings - Fork 140
RuntimeWarning: coroutine 'ExecutionContext.execute_field.<locals>.await_result' was never awaited
-- happens when a sibling resolver raises an error.
#236
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
Comments
RuntimeWarning: coroutine 'ExecutionContext.execute_field.<locals>.await_result' was never awaited
-- async resolvers aren't awaited if a non-nullable sibling resolver raises an error.
RuntimeWarning: coroutine 'ExecutionContext.execute_field.<locals>.await_result' was never awaited
-- async resolvers aren't awaited if a non-nullable sibling resolver raises an error.RuntimeWarning: coroutine 'ExecutionContext.execute_field.<locals>.await_result' was never awaited
-- happens when a sibling non-nullable resolver raises an error.
RuntimeWarning: coroutine 'ExecutionContext.execute_field.<locals>.await_result' was never awaited
-- happens when a sibling non-nullable resolver raises an error.RuntimeWarning: coroutine 'ExecutionContext.execute_field.<locals>.await_result' was never awaited
-- happens when a sibling resolver raises an error.
I'm having trouble submitting writing a test for this, i can't seem to catch it with
attempt @pytest.mark.asyncio
async def cancelled_sibling_async_resolvers_do_not_print_warning():
async def async_resolver(obj, info):
return 'foo'
schema = GraphQLSchema(
GraphQLObjectType(
"Query",
{
"syncNullError": GraphQLField(
GraphQLNonNull(GraphQLString), resolve=lambda _obj, _info: None
),
"asyncResolver": GraphQLField(
GraphQLNonNull(GraphQLString), resolve=async_resolver
),
},
)
)
document = parse(
"""
{
asyncResolver
syncNullError
}
"""
)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
result = await execute(schema, document)
print(w)
breakpoint()
fwiw i did hack together a "fix" though which removes the warnings, which is what i was hoping to eventually incorporate: https://i.fluffy.cc/c7fMHMcxqKfd4BKx7JrZSMQ9SMW4mQwQ.html#L28-31,L118-122 (adds an when/if i get more time soon i'll pick this back up. thanks! |
I'll look into it as soon as I find some time. Can you check whether the problem still exists in v3.3.0a7? |
@Cito looks like it, yes.
thanks! |
graphql-core/tests/execution/test_executor.py Line 525 in 416247c
|
@magicmark I'd say this test is supposed to replicate the following spec wording for sync + async: https://spec.graphql.org/October2021/#sel-GANPLFABABqEozF For Py > 3.11, a |
Thanks @erikwrede! Looks like my proposed change is spec compliant.
may be cancelled to avoid unnecessary work. <-- we currently do not cancel the coroutine, hence the warning. Explicitly calling TaskGroup could also work! Will look into if that (and see if we're bound by version requirements/polyfils are available) thanks! |
gather() returns when the first exception is raised, but does not cancel any remaining tasks. These continue to run which is inefficient, and can also cause problems if they access shared resources like database connections. Fixes: graphql-python#236
This is causing a problem for us where the zombie resolvers continue using the SQLAlchemy session after it has been closed, resulting in leaked database connections. I've submitted #238 with a possible solution to this. |
gather() returns when the first exception is raised, but does not cancel any remaining tasks. These continue to run which is inefficient, and can also cause problems if they access shared resources like database connections. Fixes: graphql-python#236
gather() returns when the first exception is raised, but does not cancel any remaining tasks. These continue to run which is inefficient, and can also cause problems if they access shared resources like database connections. Fixes: graphql-python#236
Repro
Prints
Version info
I'm guessing what could be happening here is that:
bar
) bubbles up and cancels execution for the rest of the type's fieldsfoo
async resolver functionWhich makes total sense -- and indeed if we do
schema.execute("{ bar foo }")
we don't see the warning printed -- because the async function never even gets kicked off.I think maybe we need to be calling
task.cancel()
or.close()
somewhere?(originally misatttributed to strawberry strawberry-graphql/strawberry#3820)
Thanks!
The text was updated successfully, but these errors were encountered: