Skip to content

Cancel asyncio iteration task on unsubscription #184

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
Jun 22, 2018
Merged

Cancel asyncio iteration task on unsubscription #184

merged 1 commit into from
Jun 22, 2018

Conversation

ciscorn
Copy link
Contributor

@ciscorn ciscorn commented Jun 2, 2018

I'm using graphql-python/graphql-ws with graphql-python/graphql-core.

The following error frequently occurs when a GQL subscription is unsubscribed.

Task was destroyed but it is pending!
task: <Task pending coro=<iterate_asyncgen() done, defined at
../graphql/execution/executors/asyncio_utils.py:129>
wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x10ac5c5b8>()]>>

This is because the asyncio task is started but not cancelled properly when being unsubscribed.

This PR also simplified asyncio_utils.py, which is unreasonably complicated.

@syrusakbary
Copy link
Member

I love this PR!
I will have to double check it working in more environments since the integration with rx is tricky, but once done I will be super happy to merge 👍

@syrusakbary
Copy link
Member

I just tested along with graphql-python/graphql-ws#13 and it works like a charm. Merging 👏

@syrusakbary syrusakbary merged commit 4d2f7e7 into graphql-python:master Jun 22, 2018
@ciscorn ciscorn deleted the stop-asyncgen branch June 22, 2018 02:02
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 this pull request may close these issues.

2 participants