Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing InterruptException to download task not a good idea #81

Closed
tanmaykm opened this issue Aug 24, 2024 · 2 comments · Fixed by #82
Closed

Throwing InterruptException to download task not a good idea #81

tanmaykm opened this issue Aug 24, 2024 · 2 comments · Fixed by #82

Comments

@tanmaykm
Copy link
Member

Interrupting the download task by scheduling an InterruptException on to it, like what we do here is not a good idea. It can lead to data race conditions and corruption.

We need to replace it with something that is safe. Ref JuliaLang/Downloads.jl#255

@vtjnash
Copy link
Member

vtjnash commented Aug 26, 2024

It looks like the Downloads code normally provides 2 APIs for this. One difficult option is to call done! on the Easy object handle inside Downloads. It is very difficult to access this object, either via an easy_hook or progress callback:

downloader = Downloads.Downloader()
downloader.easy_hook = (easy, info) -> global current_download = easy

Or an easy option is to call close(output), which will automatically trigger the safe destruction of the download object the next time any output is received (or if the timeout is reached or other error occurs)

@tanmaykm
Copy link
Member Author

Yeah, but this feels inadequate... can't think of a good way to have parallel requests and keep track of the easy handle without Downloads.jl exposing some nicer way to do that.

I have put up JuliaLang/Downloads.jl#256 with a solution that we discussed for JuliaLang/Downloads.jl#255. We can probably switch to something like that once it is available?

tanmaykm added a commit that referenced this issue Sep 24, 2024
Detect if we are using a newer version of Download.jl that supports interrupting of requests natively and use that instead of throwing `InterruptException`.

ref: JuliaLang/Downloads.jl#256 and JuliaLang/Downloads.jl#259

fixes: #81
tanmaykm added a commit that referenced this issue Sep 24, 2024
Detect if we are using a newer version of Download.jl that supports interrupting of requests natively and use that instead of throwing `InterruptException`.

ref: JuliaLang/Downloads.jl#256 and JuliaLang/Downloads.jl#259

fixes: #81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants