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

Panic when mixing future_sync/desync #11

Open
overflowz opened this issue Mar 5, 2023 · 0 comments
Open

Panic when mixing future_sync/desync #11

overflowz opened this issue Mar 5, 2023 · 0 comments

Comments

@overflowz
Copy link

overflowz commented Mar 5, 2023

Hi,

The following code causes panic, saying thread 'desync jobs thread' panicked at 'there is no reactor running, must be called from the context of a Tokio 1.x runtime'

use desync::Desync;

#[tokio::main]
async fn main() {
    let desync = Desync::new(0);
    
    desync.future_desync(|_| async move {
        tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
        tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
    })
    .detach();

    let _ = desync.future_sync(|_| async move {
        tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
    })
    .await;
}

it happens when I call the second sleep inside the future_desync call, any thoughts? :)

EDIT: it does not happen if I use async_std's sleep instead. Would it be better (and safe) for me to use async_std's features instead of tokio ones?

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

No branches or pull requests

1 participant