Skip to content

Comments

feat: impl spawn_catch_unwind()#319

Open
SteveLauC wants to merge 1 commit intobytedance:masterfrom
SteveLauC:feat/catch_panic
Open

feat: impl spawn_catch_unwind()#319
SteveLauC wants to merge 1 commit intobytedance:masterfrom
SteveLauC:feat/catch_panic

Conversation

@SteveLauC
Copy link
Contributor

What does this PR do

Adds a new spawn function that will catch the spawned task's panic.

Closes #314

Comment on lines -354 to -356
/// In this example, a server is started and `spawn` is used to start a new task
/// that processes each received connection.
///
Copy link
Contributor Author

@SteveLauC SteveLauC Nov 2, 2024

Choose a reason for hiding this comment

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

This is a copy-paste error, since the provided example is not a TCP server, let's just remove this sentence.

T: Future + 'static,
T::Output: 'static,
{
use futures::{FutureExt, TryFutureExt};
Copy link
Member

Choose a reason for hiding this comment

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

Using futures_util instead of futures can reduce dependencies. Or fork CatchUnwind can avoid introducing new dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or fork CatchUnwind can avoid introducing new dependency.

Yeah, this makes more sense

Copy link
Member

Choose a reason for hiding this comment

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

Could you change in any of these 2 ways?
Note if you choose to fork code, remember to add enough note for the copyright.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you change in any of these 2 ways?

Yeah, I will, I am just busy with my work.

Note if you choose to fork code, remember to add enough note for the copyright.

Get it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Catch the panics within spawned async tasks

2 participants