Commit ce1843d
fix(async): close awaitables require_await declines to await
require_await raised before awaiting, so the awaitable handed to it was
never awaited and never closed. async_generator_to_sync calls it as
require_await(async_gen.__anext__()), which meant the orphaned coroutine
was created inside the library and no caller could reach it to clean up.
CPython emitted "RuntimeWarning: coroutine method 'asend' ... was never
awaited" while finalizing the async generator; the pytest config's
filterwarnings = error turned that into an exception inside __del__,
surfacing as an unraisable that failed the 3.13 and 3.14 jobs.
require_await now takes ownership of the awaitable either way, closing it
before raising when inactive. This matches maybe_submit, which hands the
awaitable back to the caller when inactive rather than dropping it. Use
getattr for close since Awaitable does not guarantee it.
test_require_await_outside_context papered over this with a manual
close(); it now asserts the coroutine was closed, which fails without the
fix on every supported version rather than only on 3.13+.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>1 parent 76f5114 commit ce1843d
2 files changed
Lines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
71 | 76 | | |
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
75 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
76 | 86 | | |
77 | 87 | | |
78 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
182 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
183 | 187 | | |
184 | 188 | | |
185 | 189 | | |
| |||
0 commit comments