Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancel tokens and abort tasks on drop #1138

Merged
merged 3 commits into from
Feb 14, 2025
Merged

Cancel tokens and abort tasks on drop #1138

merged 3 commits into from
Feb 14, 2025

Conversation

shepmaster
Copy link
Member

When a client disconnects, Axum drops our future. Any tasks we've spawned need to be properly notified to also exit. Enhance tasks to be aborted and cancellation tokens to be triggered when dropped.

I hope that this helps clear up some of the cases where the playground thinks that a container is still running after it has exited.

`JoinSet`s already abort all their tasks when the set is dropped, so
nothing to worry about there.

Blocking tasks aren't really abortable, so I didn't change those.
@shepmaster shepmaster added the maintenance Keeping the wheels turning label Feb 14, 2025
We'd previously done this for one specific usage via the
`CancelOnDrop` wrapper. This works for the more complicated case where
we need to continue to clone the token. Simpler cases can use the
`DropGuard` directly.
@shepmaster shepmaster merged commit f698118 into main Feb 14, 2025
7 checks passed
@shepmaster
Copy link
Member Author

I hope that this helps clear up some of the cases where the playground thinks that a container is still running after it has exited.

Narrator: It did not.

@shepmaster shepmaster deleted the careful-dropping branch February 15, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Keeping the wheels turning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant