amaranth icon indicating copy to clipboard operation
amaranth copied to clipboard

Use asyncgen hooks to call aclose()

Open agrif opened this issue 1 week ago • 3 comments

Closes #1638.

I originally had finalizer() cause a warning if it failed to run aclose(), but this ended up making the tests fairly noisy on Python <= 3.12. Instead, I added a note to the documentation.

I don't understand why those same tests did not cause the RuntimeError I saw. I'm worried that there is some subtle issue with the order simulator coroutines are being cleaned up. In the meantime, this fix should at least be an improvement.

Let me know if you'd like any changes.

agrif avatar Dec 11 '25 14:12 agrif

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 91.29%. Comparing base (1ef99a5) to head (845bea1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1645      +/-   ##
==========================================
+ Coverage   91.28%   91.29%   +0.01%     
==========================================
  Files          44       44              
  Lines       11471    11486      +15     
  Branches     2236     2237       +1     
==========================================
+ Hits        10471    10486      +15     
  Misses        837      837              
  Partials      163      163              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Dec 11 '25 14:12 codecov[bot]

I don't understand why those same tests did not cause the RuntimeError I saw. I'm worried that there is some subtle issue with the order simulator coroutines are being cleaned up. In the meantime, this fix should at least be an improvement.

I'll do my best to reproduce and test for this issue before merging it.

whitequark avatar Dec 12 '25 00:12 whitequark

The easiest way to find these tests is to add a warning (or exception, or ...) to the very end of finalizer(). Execution falls through to the end if it fails to run aclose() for any reason.

agrif avatar Dec 12 '25 01:12 agrif