Commit ab61ec2
authored
[mypyc] Free coroutine after await encounters StopIteration (#19231)
Previously the awaited coroutine could stay alive until the coroutine
that performed the await was freed, delaying object reclamation. The
reference counting analysis doesn't understand registers spilled to the
environment, so we need to manually clear the value.
Consider code like this:
```
async def foo() -> None:
await bar()
await zar()
```
Previously, the `bar()` coroutine was only freed at end of `foo()`. Now
we release it before `await zar()`, as expected.1 parent 71942c0 commit ab61ec2
1 file changed
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
940 | 940 | | |
941 | 941 | | |
942 | 942 | | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
943 | 947 | | |
944 | 948 | | |
945 | 949 | | |
| |||
0 commit comments