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

Add panic propagation #37

Merged
merged 2 commits into from
Nov 27, 2022
Merged

Add panic propagation #37

merged 2 commits into from
Nov 27, 2022

Conversation

notgull
Copy link
Member

@notgull notgull commented Oct 31, 2022

Resolves #36 by making it so, when the std feature is enabled, panics are caught and then propagated when the Task is polled. This generally makes more sense than whatever thread polling the Runnable panicking.

I had to adjust some tests which seemed to assume that the Runnable panics rather than the Task, I'm not sure whether this is an intended feature I'm overwriting or not.

@taiki-e
Copy link
Collaborator

taiki-e commented Nov 26, 2022

Hmm... It is a bit annoying that it works differently with and without the feature flags.

I think it would be possible to use the builder to allow users to explicitly opt-in to this behavior, but given that the current behavior is somewhat odd, I'm not clear that that is a good idea.

@notgull
Copy link
Member Author

notgull commented Nov 26, 2022

I think it would be possible to use the builder to allow users to explicitly opt-in to this behavior, but given that the current behavior is somewhat odd, I'm not clear that that is a good idea.

Good idea, just to make sure no one is surprised by the new behavior. I've rebased on master and made panic propagation a thing that can be set in the builder.

Copy link
Collaborator

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@notgull notgull merged commit 2e0a196 into smol-rs:master Nov 27, 2022
@notgull notgull deleted the panic branch November 27, 2022 03:02
@notgull notgull mentioned this pull request Mar 24, 2023
notgull added a commit that referenced this pull request Mar 24, 2023
- Ensure that the allocation doesn't exceed `isize::MAX` (#32)
- Add `FallibleTask::is_finished()` (#34)
- Add a metadata generic parameter to tasks (#33)
- Add panic propagation to tasks (#37)
- Add a way to tell if the task was woken while running from the schedule function (#42)
notgull added a commit to smol-rs/async-executor that referenced this pull request Nov 17, 2023
After smol-rs/async-task#37 I meant to add this to the executor. This
commit makes it so all panics are surfaced in the tasks that the user
calls. Hopefully this improves ergonomics.

Signed-off-by: John Nunley <dev@notgull.net>
fogti pushed a commit to smol-rs/async-executor that referenced this pull request Nov 21, 2023
After smol-rs/async-task#37 I meant to add this to the executor. This
commit makes it so all panics are surfaced in the tasks that the user
calls. Hopefully this improves ergonomics.

Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: Alain Zscheile <fogti+devel@ytrizja.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Unit test with expected panic message randomly fails because of crate-specific panic message
2 participants