diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-07-18 09:27:15 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-07-18 10:02:33 +0300 |
commit | ecd9cf74e670afb112189171486e91161bd5580d (patch) | |
tree | 7362de07e5c9a40439bd9fbbb796025b8e7508a1 /src/cmd | |
parent | 5d016c96c8b2b3290d25baa838c8816edeecab8a (diff) | |
download | obnam2-ecd9cf74e670afb112189171486e91161bd5580d.tar.gz |
fix: use an explicit tokio runtime
Create a tokio runtime so that the non-async function for chunkify can
call an async function and have that create and run background tasks.
Brown paper bag mistake: I did the development of this in a separate
program with an async main function. When I integrated it into Obnam
proper, which doesn't have an async main function (yet), I didn't
actually test it works, only that it compiles. Stupid, stupid, stupid.
I know better.
Sponsored-by: author
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/chunkify.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/cmd/chunkify.rs b/src/cmd/chunkify.rs index 10121a9..79fbdea 100644 --- a/src/cmd/chunkify.rs +++ b/src/cmd/chunkify.rs @@ -2,13 +2,13 @@ use crate::config::ClientConfig; use crate::engine::Engine; use crate::error::ObnamError; use crate::workqueue::WorkQueue; -use futures::executor::block_on; use serde::Serialize; use sha2::{Digest, Sha256}; use std::path::PathBuf; use structopt::StructOpt; use tokio::fs::File; use tokio::io::{AsyncReadExt, BufReader}; +use tokio::runtime::Runtime; use tokio::sync::mpsc; // Size of queue with unprocessed chunks, and also queue of computed @@ -22,7 +22,8 @@ pub struct Chunkify { impl Chunkify { pub fn run(&self, config: &ClientConfig) -> Result<(), ObnamError> { - block_on(self.run_async(config)) + let rt = Runtime::new()?; + rt.block_on(self.run_async(config)) } pub async fn run_async(&self, config: &ClientConfig) -> Result<(), ObnamError> { |