GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix asyncgen finalizer by youknowone · Pull Request #6761 · RustPython/RustPython

Conversation

@youknowone

@youknowone youknowone commented Jan 17, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed async generator finalization to ensure finalizers are properly invoked during cleanup operations, including destructor paths
    • Enhanced error handling for finalizer execution with improved error routing to exception handlers
    • Strengthened state management to accurately track generator closure status throughout the lifecycle

✏️ Tip: You can customize this high-level summary in your review settings.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@coderabbitai

coderabbitai Bot commented Jan 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This change enhances async generator finalization by ensuring finalizers are properly invoked, managing generator state closure during termination, and routing finalizer errors to the VM's unraisable hook. The destructor now unconditionally attempts finalizer calls and updates error messaging.

Changes

Cohort / File(s) Summary
Async generator finalizer and state management
crates/vm/src/builtins/asyncgenerator.rs
Adds finalizer invocation with error handling via vm.run_unraisable; updates destructor to always call finalizers and changes error message; explicitly sets ag.inner.closed = true and state to Closed in termination paths (yield_close, check_error)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • sys.set_asyncgen_hook #6439: Directly modifies finalizer storage and invocation logic in the same async generator file.
  • Upgrade threading to 3.13.11; sys.setprofile & impl more threading #6691: Updates async generator finalizer hook sourcing to use VM fields.

Suggested reviewers

  • fanninpm
  • ShaharNaveh

Poem

🐰 A finalizer's tale, so precise and fine,
State closure marks the end of the line,
Error handling routed, with care divine,
Async generators dance in perfect design!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix asyncgen finalizer' directly and clearly summarizes the main change: fixing finalizer handling in async generators. It is specific, concise, and accurately reflects the primary objective of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands and usage tips.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone force-pushed the asyncgen branch from c48157d to c83681b Compare January 18, 2026 02:17
@youknowone
fix asyncgen
daf8863
@youknowone
youknowone force-pushed the asyncgen branch from c83681b to daf8863 Compare January 18, 2026 04:24
@youknowone
youknowone marked this pull request as ready for review January 18, 2026 05:08
@youknowone youknowone changed the title fix asyncgen fix asyncgen finalizer Jan 18, 2026
@youknowone
youknowone merged commit 7c7b824 into RustPython:main Jan 18, 2026
13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone deleted the asyncgen branch January 18, 2026 05:18
@coderabbitai coderabbitai Bot mentioned this pull request Feb 1, 2026
Update asyncio to 3.14.2 #6902
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Feb 11, 2026
Update doctest,test_generators from v3.14.2 and fix generator bugs #7067
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@youknowone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.