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

[Feature] Access to Abort Signal from Client #2219

Closed
Kakapio opened this issue Mar 29, 2024 · 3 comments
Closed

[Feature] Access to Abort Signal from Client #2219

Kakapio opened this issue Mar 29, 2024 · 3 comments

Comments

@Kakapio
Copy link

Kakapio commented Mar 29, 2024

I would like to have access to Abort Signal from the client implementation. We need access to it for some existing functionality we are looking to replace with reqwest.

cloudflare/workers-rs#510 (comment)

@seanmonstar
Copy link
Owner

Is the actual signal needed? I try to present a unified API in reqwest, without exposing internals. The signal is used to make the Drop behavior of the future the same as in non-wasm environments.

Can you do what you want without direct access?

@Kakapio
Copy link
Author

Kakapio commented Mar 29, 2024

Ah, I think we may be able to use Drop. Correct me if I'm wrong, since I'm new to Reqwest, but we could just have a handler for the functionality and pass it through like so:

// Asynchronous loop to continuously check for cancellation signal
    loop {
        tokio::select! {
            _ = sleep(Duration::from_secs(1)) => {
                println!("Async task running...");
            }
            _ = cancel_receiver.recv() => {
                println!("Cancellation signal received. Dropping task...");
                break; // Break out of the loop when cancellation signal is received
            }
        }
    }

@seanmonstar
Copy link
Owner

I believe that should do it.

@seanmonstar seanmonstar closed this as not planned Won't fix, can't repro, duplicate, stale Mar 30, 2024
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

No branches or pull requests

2 participants