-
Notifications
You must be signed in to change notification settings - Fork 115
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
Interval is Infallible #266
Comments
Thanks for the report! I think we'll need an error here in the long run, however. It's possible for the core/reactor to disappear while the |
Couldn't the same be said of any tokio-core-based |
You're right yeah, but futures with embedded handles are slightly different. If you spawn a future you're not holding on to it at all, but if you create an interval that's a handle to the reactor. In that sense we don't have a way to tell you the reactor is dropped when you spawn a future, but we do have a method of telling you once you create a handle to the reactor. |
I guess I'm not convinced that it's worth it to force all users to accept these unhandle-able If we decide that it is worth it, I think it'd be better to provide an error type that is more clear about what's happening, something like |
Is this actually causing problems? In all the usage I've personally done of these types the error fits quite nicely into the surrounding future and rarely requires much fuss to get it to work. I agree that the reactor being dropped is quite rare, but I didn't think this was a problem to begin with :( |
IMO, forcing users to I'm fine with closing this as "won't fix" or similar, but I'd like to at least add some documentation explaining that the error case here doesn't represent an actual IO error. For reference, this came up because I was asking a coworker to log errors instead of just mapping them away to |
I imagine that this discussion would be more relevant to the ongoing Tokio revamp RFC as it impacts timers. |
@cramertj hm I'm not sure I quite understand, if you do I agree though that this should certainly be documented what errors can come up! |
@alexcrichton |
Hm I think I may still be missing something? I don't think we can get away with a "void error type" here because the error can legitimately happen, and in that case aren't you required to deal with some error? I'd imagine that "some error" vs "no error" is a pretty big distinction to make, but given that I think we should buy into "some error" (due to the reactor/timer going away) it'd necessitate some level of error handling, and then following that further I think |
I guess that's the real answer to my question here-- I wasn't sure this was true. The only reasonable way that |
I suppose you could always notify and all futures again when the reactor is dropped, but after you've closed the |
You are indeed right! I suppose I'm trying to think of this wrt the futures as well, where for example I believe the implementation at https://github.com/alexcrichton/futures-timer correctly handles this. (that's my current plan for reimplementing this repo's interval in terms of). |
Interval::poll
never returns an error, but its associated error type isio::Error
. The error type should be changed toenum Never {}
or similar (eventually!
when it lands).The text was updated successfully, but these errors were encountered: