Skip to content

Commit

Permalink
Switch back to tokio 0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa committed Oct 16, 2020
1 parent 3d730ab commit 48a8b2b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 31 deletions.
30 changes: 9 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ keywords = ["image", "download"]
image = "0.23"
png = "0.16"
reqwest = { version = "0.10", features = ["gzip"] }
tokio = { version = "0.3", features = ["rt-multi-thread", "rt", "macros", "time", "fs", "sync"] }
tokio = { version = "0.2", features = ["rt-threaded", "rt-core", "macros", "rt-util", "time", "fs", "sync"] }
futures = "0.3"
custom_error = "1.7"
structopt = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion src/encoder/tile_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub enum TileBufferMsg {

async fn buffer_tiles(mut encoder: Box<dyn Encoder>) -> TileBuffer {
let (tile_sender, mut tile_receiver) = mpsc::channel(1024);
let (error_sender, error_receiver) = mpsc::channel(1);
let (mut error_sender, error_receiver) = mpsc::channel(1);
tokio::spawn(async move {
while let Some(msg) = tile_receiver.recv().await {
match msg {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ async fn download_tile(
Ok(_) => { break; },
Err(e) => {
warn!("{}. Retrying tile download in {:?}.", e, wait_time);
tokio::time::sleep(wait_time).await;
tokio::time::delay_for(wait_time).await;
wait_time *= 2;
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/network.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use log::debug;
use reqwest::{Client, header};
use std::collections::HashMap;
use std::iter::once;
use std::path::PathBuf;

use log::debug;
use reqwest::{Client, header};
use tokio::fs;
use url::Url;

Expand All @@ -17,9 +16,11 @@ use crate::ZoomError;
pub async fn fetch_uri(uri: &str, http: &Client) -> Result<Vec<u8>, ZoomError> {
if uri.starts_with("http://") || uri.starts_with("https://") {
debug!("Loading url: '{}'", uri);
let response = http.get(uri).send().await?.error_for_status()?;
let response = http.get(uri).send()
.await?.error_for_status()?;
let mut contents = Vec::new();
contents.extend(response.bytes().await?);
let bytes = response.bytes().await?;
contents.extend(bytes);
debug!("Loaded url: '{}'", uri);
Ok(contents)
} else {
Expand Down
4 changes: 2 additions & 2 deletions tests/local_dezoomifying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use dezoomify_rs::{Arguments, dezoomify, ZoomError};

/// Dezoom a file locally
#[ignore] // Ignore this test by default because it's slow in debug mode
#[tokio::test(flavor = "multi_thread")]
#[tokio::test(threaded_scheduler)]
pub async fn custom_size_local_zoomify_tiles() {
test_image(
"testdata/zoomify/test_custom_size/ImageProperties.xml",
"testdata/zoomify/test_custom_size/expected_result.jpg",
).await.unwrap()
}

#[tokio::test(flavor = "multi_thread")]
#[tokio::test(threaded_scheduler)]
pub async fn local_generic_tiles() {
test_image(
"testdata/generic/map_{{X}}_{{Y}}.jpg",
Expand Down

0 comments on commit 48a8b2b

Please sign in to comment.