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

Added handling of the case where we're within a Tokio Runtime or not #50

Merged

Conversation

PLeVasseur
Copy link
Contributor

What

Added handling of the case where we're within a Tokio Runtime or not

  • if we're within a Tokio Runtime use the current handle
  • if not, use a dedicated Tokio Runtime we have (e.g. we're within an async-std executor)

Why

To handle the current case / issue of trying to send a Request UMessage within a Zenoh Plugin on zenoh 0.11.0-rc3, which I think still uses async-std. Therefore we need to ensure we use a dedicated Tokio Runtime in that case within up-transport-zenoh-rust.

With this change, we resolve this issue pointed out on the up-linux-streamer-plugin PR:

Issue with up-transport-zenoh-rust assuming it's inside of a Tokio runtime?

…based on a check

* if we're within a Tokio Runtime use the current handle
* if not, use a dedicated Tokio Runtime we have (e.g. we're within an async-std executor)
Copy link
Contributor

@evshary evshary left a comment

Choose a reason for hiding this comment

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

Interesting. I didn't find that the plugins in zenoh are still using async_std. Also, my assumption of using tokio might be wrong. I'm ok with the current change, but maybe there is a better way to be compatible with both tokio and aync_std. Let's figure it out later.

use std::{sync::Arc, time::Duration};
use tokio::runtime::Runtime;
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to merge the crate path together.

Signed-off-by: ChenYing Kuo <[email protected]>
@evshary
Copy link
Contributor

evshary commented Jun 26, 2024

@PLeVasseur I know you might need the PR urgently for the uStreamer demo. I take the liberty to update the PR and merge it. I hope it doesn't offend you.

@evshary evshary merged commit b977153 into eclipse-uprotocol:main Jun 26, 2024
7 checks passed
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.

2 participants