Use asyncgen hooks to call aclose()
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.
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.
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.
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.