Skip to content

Commit

Permalink
add test to reproduce #1842
Browse files Browse the repository at this point in the history
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
  • Loading branch information
hawkw committed Nov 27, 2019
1 parent 34d751b commit 0637bc6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tokio/src/task/local.rs
Expand Up @@ -724,4 +724,32 @@ mod tests {
join2.await.unwrap()
});
}
#[test]
fn drop_cancels_tasks() {
// This test reproduces issue #1842
use crate::sync::oneshot;
use std::time::Duration;

let mut rt = runtime::Builder::new()
.enable_time()
.basic_scheduler()
.build()
.unwrap();

let (started_tx, started_rx) = oneshot::channel();

let local = LocalSet::new();
local.spawn_local(async move {
started_tx.send(()).unwrap();
loop {
crate::time::delay_for(Duration::from_secs(3600)).await;
}
});

local.block_on(&mut rt, async {
started_rx.await.unwrap();
});
drop(local);
drop(rt);
}
}

0 comments on commit 0637bc6

Please sign in to comment.