tests/worker-task-abort.rs: switch to async

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-08-29 10:05:43 +02:00
parent 0cdb8d9c5b
commit 968398930d
1 changed files with 5 additions and 8 deletions

View File

@ -6,8 +6,6 @@ extern crate proxmox_backup;
extern crate tokio; extern crate tokio;
extern crate nix; extern crate nix;
use tokio::prelude::future::lazy;
use proxmox::tools::try_block; use proxmox::tools::try_block;
use proxmox_backup::server; use proxmox_backup::server;
@ -41,7 +39,8 @@ fn worker_task_abort() -> Result<(), Error> {
let errmsg: Arc<Mutex<Option<String>>> = Arc::new(Mutex::new(None)); let errmsg: Arc<Mutex<Option<String>>> = Arc::new(Mutex::new(None));
let errmsg1 = errmsg.clone(); let errmsg1 = errmsg.clone();
tokio::run(lazy(move || { let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async move {
let init_result: Result<(), Error> = try_block!({ let init_result: Result<(), Error> = try_block!({
server::create_task_control_socket()?; server::create_task_control_socket()?;
@ -51,7 +50,7 @@ fn worker_task_abort() -> Result<(), Error> {
if let Err(err) = init_result { if let Err(err) = init_result {
eprintln!("unable to start daemon - {}", err); eprintln!("unable to start daemon - {}", err);
return Ok(()); return;
} }
let errmsg = errmsg1.clone(); let errmsg = errmsg1.clone();
@ -80,10 +79,8 @@ fn worker_task_abort() -> Result<(), Error> {
server::abort_worker_async(wid.parse::<server::UPID>().unwrap()); server::abort_worker_async(wid.parse::<server::UPID>().unwrap());
} }
} }
});
Ok(()) rt.shutdown_on_idle();
}));
let data = errmsg.lock().unwrap(); let data = errmsg.lock().unwrap();
match *data { match *data {