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

A way to check if Runtime has panicked tasks #1999

Closed
MOZGIII opened this issue Dec 20, 2019 · 4 comments
Closed

A way to check if Runtime has panicked tasks #1999

MOZGIII opened this issue Dec 20, 2019 · 4 comments
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-runtime Module: tokio/runtime

Comments

@MOZGIII
Copy link
Contributor

MOZGIII commented Dec 20, 2019

Version

0.2.6

Platform

Irrelevant, it's an API issue.

Description

I'm looking for some way to detect whether the panics occurred or not at Runtime.
My use case is pretty simple, I just need it to fail tests if something goes wrong.
I understand I can simply use a basic_scheduler, and with that setup it would panic the running thread. That's what I ended up doing right now.

Is there a plan to enhance the API to provide some was of doing this for a multi-threaded scheduler?

@mikhailOK
Copy link

I understand I can simply use a basic_scheduler, and with that setup it would panic the running thread. That's what I ended up doing right now.

Does it actually work?
I'm observing panics getting caught with basic_scheduler: #2002

@MOZGIII
Copy link
Contributor Author

MOZGIII commented Dec 21, 2019

It worked and failed my test. I deliberately created a condition where the tested would fail, and the panic successfully failed the test. With default Runtime, it only prints the panic to console, but the test is green.

@MOZGIII
Copy link
Contributor Author

MOZGIII commented Dec 21, 2019

Since I'm doing all this in the test environment, I'm doing a block_on - that might be the reason why it works for me while not working in other scenarios.

@carllerche carllerche added the C-enhancement Category: A PR with an enhancement or bugfix. label Dec 21, 2019
@Darksonn Darksonn added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-runtime Module: tokio/runtime and removed C-enhancement Category: A PR with an enhancement or bugfix. labels Jul 25, 2020
@Darksonn
Copy link
Contributor

Closing in favor of #2699.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-runtime Module: tokio/runtime
Projects
None yet
Development

No branches or pull requests

4 participants