-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
gracefully cancel a request #256
Conversation
Adds a way to gracefully cancel an ongoing request. The `request` method accepts an additional `interrupt` keyword which can be a `Base.Event`. When it is triggered, the [`curl_multi_remove_handle`](https://curl.se/libcurl/c/curl_multi_remove_handle.html) is invoked, which interrupts the easy handle gracefully. It closes the `output` and `progress` channels of the `Easy` handle to unblock the waiting request task, which then terminates with a `RequestError`. Ref: JuliaLang#255
Requesting some 👀 on this... |
else | ||
lock(multi.lock) do | ||
check_multi_info(multi) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a related change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. When the easy handle is removed this callback is invoked with CURL_POLL_REMOVE
. If I recollect, calling check_multi_info
was required to clean up and unblock the request
method that's blocking on some of the channels.
@IanButterworth can we use this in Pkg downloads to not get all the curl errors if a user ctrl C during e.g. package downloading? |
I'm not sure we can stop the curl async processes from receiving interrupts? |
I think we'd need JuliaLang/julia#49541 to intercept it and then call this cancel? |
Cancelling an upload (PUT) request using the mechanism introduced in JuliaLang#256 was not effective. The upload task was not interrupted, which still blocks and the call to `request` does not return. With this change, cancelling also closes the `input` stream of the request to unblock the upload task. Also changed the `interrupted` variable to be an `Atomic{Bool}`. Ref discussion [here](JuliaLang#256 (comment)).
Cancelling an upload (PUT) request using the mechanism introduced in JuliaLang#256 was not effective. The upload task was not interrupted, which still blocked and the call to `request` did not return. With this change, cancelling also closes the `input` stream of the request to unblock the upload task. Also changed the `interrupted` variable to be an `Atomic{Bool}`. Ref discussion [here](JuliaLang#256 (comment)).
Cancelling an upload (PUT) request using the mechanism introduced in JuliaLang#256 was not effective. The upload task was not interrupted, which still blocked and the call to `request` did not return. With this change, cancelling also closes the `input` stream of the request to unblock the upload task. Also changed the `interrupted` variable to be an `Atomic{Bool}`. Ref discussion [here](JuliaLang#256 (comment)).
Cancelling an upload (PUT) request using the mechanism introduced in #256 was not effective. The upload task was not interrupted, which still blocked and the call to `request` did not return. With this change, cancelling also closes the `input` stream of the request to unblock the upload task. Also changed the `interrupted` variable to be an `Atomic{Bool}`. Ref discussion [here](#256 (comment)).
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
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
Adds a way to gracefully cancel an ongoing request. The
request
method accepts an additionalinterrupt
keyword which can be aBase.Event
. When it is triggered, thecurl_multi_remove_handle
is invoked, which interrupts the easy handle gracefully. It closes theoutput
andprogress
channels of theEasy
handle to unblock the waiting request task, which then terminates with aRequestError
.Ref: #255