summaryrefslogtreecommitdiff
path: root/cli/worker.rs
diff options
context:
space:
mode:
authorandy finch <andyfinch7@gmail.com>2019-04-12 18:39:31 -0400
committerRyan Dahl <ry@tinyclouds.org>2019-04-12 18:39:31 -0400
commitd3bd5879c3b1a26cc09a5374bf2b5ee63071fe29 (patch)
treeff377a980480149f3d3d4351a40e57546f675efa /cli/worker.rs
parente0edcc9c1b025c2b02eb5b50ae7a86089d1c4d61 (diff)
better wait for removed_from_resource_table_on_close test (#2104)
Diffstat (limited to 'cli/worker.rs')
-rw-r--r--cli/worker.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/cli/worker.rs b/cli/worker.rs
index 527183182..dea5e534a 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -258,7 +258,6 @@ mod tests {
use deno::js_check;
use futures::future::lazy;
use std::sync::atomic::Ordering;
- use std::thread;
#[test]
fn execute_mod() {
@@ -379,14 +378,16 @@ mod tests {
let resource = worker.state.resource.clone();
let rid = resource.rid;
- tokio::spawn(lazy(move || {
- worker.then(move |r| -> Result<(), ()> {
+ let worker_future = worker
+ .then(move |r| -> Result<(), ()> {
resource.close();
println!("workers.rs after resource close");
js_check(r);
Ok(())
- })
- }));
+ }).shared();
+
+ let worker_future_ = worker_future.clone();
+ tokio::spawn(lazy(move || worker_future_.then(|_| Ok(()))));
assert_eq!(resources::get_type(rid), Some("worker".to_string()));
@@ -395,9 +396,7 @@ mod tests {
assert!(r.is_ok());
debug!("rid {:?}", rid);
- // TODO Need a way to get a future for when a resource closes.
- // For now, just sleep for a bit.
- thread::sleep(std::time::Duration::from_millis(1000));
+ worker_future.wait().unwrap();
assert_eq!(resources::get_type(rid), None);
})
}