hunger / downloader

Simple HTTP/HTTPS file downloader crate.
27 stars 9 forks source link

Panic when used in async application #11

Open rgreinho opened 2 years ago

rgreinho commented 2 years ago

I have a small async application which needs to download a bunch of files, therefore I decided to use this library to re-implement the downloading part.

It worked fairly well, except that at the end of the downloads it fails with the following message:

The application panicked (crashed).
Message:  Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.

This line https://github.com/hunger/downloader/blob/0.2.6/src/backend.rs#L168 seems to be the culprit, but I am not entirely sure how to workaround it.

I am using the following dependencies for downloader and tokio:

downloader = { version = "0.2.6", features = ["tui", "verify"]}
tokio = { version = "1.12.0", features = ["full"] }
hunger commented 2 years ago

Yes, that is definitely an issue. Maybe the runtime could be passed in or something.