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

Any way to cancel watch? #9

Closed
arthurprs opened this issue Jun 23, 2016 · 12 comments
Closed

Any way to cancel watch? #9

arthurprs opened this issue Jun 23, 2016 · 12 comments

Comments

@arthurprs
Copy link
Contributor

Is there any way to cancel a watch? Even a simple Client wide close would be really useful.

@jimmycuadra
Copy link
Owner

Right now it blocks until a change happens or until there is a network error of some sort. Being able to cancel it early seems like a good idea. What sort of API do you imagine for it? In the meantime, you could run the watch inside a thread and kill the thread if you need to cancel the watch early.

@arthurprs
Copy link
Contributor Author

The problem is that Rust doesn't provide any reasonable way to kill a thread right now (and probably never will). At least as far as I know.

I checked hyper and I couldn't see any support for canceling either so I ran out of ideas.

@jmlMetaswitch
Copy link

A time-out and/or a non-blocking method would be a good start (like mpsc). I assume Hyper supports this.

I see you've been asking about time-outs in hyperium/hyper#417, but it appears that client.set_read_timeout() has been added now (https://hyper.rs/hyper/0.8.0/hyper/client/struct.Client.html).

I'm guessing that HTTP makes a non-blocking method harder.

Would you consider adding a time-out for watches, so that we can then intermittently check whether to terminate in watch threads?

@jimmycuadra
Copy link
Owner

I'm working on updating this crate to user hyper 0.11, which uses an async model based on futures and tokio. You can cancel a future by simply dropping it (letting it go out of scope). I'll see how this plays out for a watch cancellation API as I get further into it.

@jmlMetaswitch
Copy link

Just so you know, I fully support you spending your free time on this issue, @jimmycuadra! Thank you :-)

I don't suppose you have an idea when this work might be available, do you?

@jimmycuadra
Copy link
Owner

No ETA, but I'll try to make some more progress on this soon!

@jimmycuadra
Copy link
Owner

I worked on it a bit tonight but it's pretty tough and progress is slow. If you'd like to see what I have so far, take a look at the "async" branch.

@jmlMetaswitch
Copy link

Thanks. I'll probably have to read up on hyper first, but that wouldn't be a bad thing!

@jimmycuadra
Copy link
Owner

Update: Made lots of progress. The next version of the crate is largely done. I still need to update the tests to use the new async functions and improve some docs. Then I will take a look at the watch function and make sure there's a good way to cancel the watch.

@jmlMetaswitch
Copy link

Great. Really appreciate your work on this.

jimmycuadra added a commit that referenced this issue Jul 15, 2017
@jmlMetaswitch
Copy link

This looks great. Thanks. Are you planning to move up to a new release soon, or are you planning to get more features in first?

@jimmycuadra
Copy link
Owner

I'm gonna add the members and auth API and then make a new release.

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

No branches or pull requests

3 participants