Limit tokio threads
This commit is contained in:
parent
12b3f12859
commit
7f47772dcb
1 changed files with 19 additions and 10 deletions
29
src/main.rs
29
src/main.rs
|
|
@ -56,23 +56,32 @@ struct Opts {
|
||||||
overwrite: bool,
|
overwrite: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
fn main() -> anyhow::Result<()> {
|
||||||
async fn main() -> anyhow::Result<()> {
|
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
|
||||||
let opts = Opts::parse();
|
let rt = tokio::runtime::Builder::new_multi_thread()
|
||||||
|
.enable_all()
|
||||||
|
// the default is 512, it can get out of hand.
|
||||||
|
.max_blocking_threads(8)
|
||||||
|
.build()?;
|
||||||
|
|
||||||
let torrent =
|
rt.block_on(async move {
|
||||||
if opts.torrent_path.starts_with("http://") || opts.torrent_path.starts_with("https://") {
|
let opts = Opts::parse();
|
||||||
|
|
||||||
|
let torrent = if opts.torrent_path.starts_with("http://")
|
||||||
|
|| opts.torrent_path.starts_with("https://")
|
||||||
|
{
|
||||||
torrent_from_url(&opts.torrent_path).await?
|
torrent_from_url(&opts.torrent_path).await?
|
||||||
} else {
|
} else {
|
||||||
torrent_from_file(&opts.torrent_path)?
|
torrent_from_file(&opts.torrent_path)?
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("Torrent metadata: {:#?}", &torrent);
|
info!("Torrent metadata: {:#?}", &torrent);
|
||||||
|
|
||||||
let builder = TorrentManagerBuilder::new(torrent, opts.output_folder).overwrite(opts.overwrite);
|
let builder =
|
||||||
let manager_handle = builder.start_manager().await?;
|
TorrentManagerBuilder::new(torrent, opts.output_folder).overwrite(opts.overwrite);
|
||||||
manager_handle.wait_until_completed().await?;
|
let manager_handle = builder.start_manager().await?;
|
||||||
Ok(())
|
manager_handle.wait_until_completed().await?;
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue