Skip to content

Panic when mixing future_sync/desync #11

Description

@overflowz

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions