downloader icon indicating copy to clipboard operation
downloader copied to clipboard

Panic when used in async application

Open rgreinho opened this issue 3 years ago • 1 comments
trafficstars

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"] }

rgreinho avatar Dec 10 '21 05:12 rgreinho

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

hunger avatar Dec 10 '21 15:12 hunger