◐ Shell
clean mode source ↗

fix asyncgen finalizer by youknowone · Pull Request #6761 · RustPython/RustPython

📝 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

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

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