Fix async await exception propagation#386
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3265538e7b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let gather_mut = gather.get_mut(self.heap); | ||
| let task_ids = mem::take(&mut gather_mut.task_ids); | ||
| let waiter = gather_mut.waiter; | ||
| // Drop the HeapRead before cancel_task which may free heap objects |
There was a problem hiding this comment.
Remove gather waiters before dropping failed gather
When a gathered coroutine fails in fail_future, this branch only takes task_ids/waiter and then later dec_refs the gather, but it never removes gather.pending_calls from scheduler.gather_waiters. In a mixed asyncio.gather(...) (coroutine + direct external future), if the host resumes with multiple results in one FutureSnapshot.resume call and processes the coroutine failure first, a later result for the sibling external future still hits the stale gather_waiters entry and resolve_future will try to heap.read a freed gather, causing a panic.
Useful? React with 👍 / 👎.
|
i will complete this pr by tomorrow, i am still working on it, i needed feedback from codex and devin, that's why i created the pr |
Summary
try/exceptaround directawaitexpressions can catch them.asyncio.gather(...)failures instead of surfacing sibling task cancellation.Testing
PATH="$HOME/.cargo/bin:$PATH" make format-rsmake dev-pyuv run pytest crates/monty-python/tests/test_start.py::test_future_snapshot_resume_exception_caught_at_await crates/monty-python/tests/test_start.py::test_future_snapshot_resume_gather_exception_caught_at_await crates/monty-python/tests/test_start.py::test_future_snapshot_resume_gathered_coroutine_exception_caught_at_await -quv run pytest crates/monty-python/tests/test_start.py -qmake lint-rsmake lint-pyuv run pytest crates/monty-python/tests/test_async.py -q