Skip to content

GH-117536: ensure asyncgens GCd before runner teardown get aclosed #117577

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

Conversation

graingert
Copy link
Contributor

@graingert graingert commented Apr 6, 2024

@graingert
Copy link
Contributor Author

some tests needed:

  • an async gen getting GCd during teardown can call await asyncio.sleep(0) without raising GeneratorExit
  • an async gen getting GCd after shutdown_asyncgens is called can call await asyncio.sleep(0) without getting GeneratorExit

@@ -573,13 +585,18 @@ async def shutdown_asyncgens(self):
"""Shutdown all active asynchronous generators."""
self._asyncgens_shutdown_called = True

if not len(self._asyncgens):
closing_agens = list(self._asyncgens)
closing_agens.extend(self._closing_asyncgens.copy())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
closing_agens.extend(self._closing_asyncgens.copy())
closing_agens.extend(self._closing_asyncgens)

@graingert
Copy link
Contributor Author

My original diagnosis of the problem was wrong, async gens .aclose() get cancelled but still scheduled

@graingert graingert closed this Apr 10, 2024
@graingert graingert deleted the ensure-asyncgens-gcd-before-runner-teardown-get-aclosed branch April 10, 2024 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants