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

An ObservableResource is not notified about observation canceling #30

Closed
aellwein opened this issue Nov 29, 2015 · 7 comments
Closed

An ObservableResource is not notified about observation canceling #30

aellwein opened this issue Nov 29, 2015 · 7 comments

Comments

@aellwein
Copy link
Contributor

I've noticed that a RST message which is supposed to cancel an existing observation, does nothing on ObservableResource. Is there no handler for that to inform the application about the observation cancelation? I think this is also related to issue #13.

@aellwein
Copy link
Contributor Author

@chrysn
WDYT maybe it is a good idea to introduce an additional cancel_observation method on ObservableResource to notify the resource about observe cancellation? Just to keep it symmetric to the existing add_observation handler?

@chrysn
Copy link
Owner

chrysn commented Mar 30, 2016

Removal of observations generally happens via the cancellation callback passed to the ServerObservation's accept method; this allows an observation to be properly cancelled (pending bugs like this one, when cancellation_callback is probably not properly called, haven't looked properly yet), even when for example it has changed its path in the meantime. (Not a situation I'd expect to be common, but possible for kind of dynamic resources.) When add_obsevation is called, eg. on a Site, the ServerObservation is passed around until it gets accepted by a resource object, and I'm in favor of establishing the relationship to that object at accept time instead of hoping that a parallel cancel_observation would find its way to the very object the add_observation found, however likely it is in most cases.

Do you have a suggestion on how to fix this bug that would be made easier if there were a cancel_observation?

@aellwein
Copy link
Contributor Author

What i am actually trying to do is to establish a producer for an observation, which is to be notified via cancel_observation (server-side cancellation, not self-triggered) to not produce the notifications anymore (by using asyncio loop, my producer just reschedules itself periodically).

With no expectation of corner cases here i am currently not aware of, i would try a naive approach of looking up the cancel_observation attribute on a ObservableResource (by convention). If this one is present, it is to be called, i think after calling remove() on the server observation. But as i said, just a naive approach, maybe it makes much more sense to somehow let the resource keep the server observation until a cancellation is needed.

@aellwein
Copy link
Contributor Author

You may close the issue, if you think that such a callback is not necessary.

@chrysn
Copy link
Owner

chrysn commented Mar 31, 2016

I see now what you are aiming for (the resource implementation needs to know when it is being observed, eg. to establish a fnotify); in light of that, my previous answer was not exactly to point.

To give me some leeway in how to implement observations, I try to keep the ServerObservation objects out of the ObservableResource as far as possible; a .cancel_observation would be possible, but as long as the actual question is "am i being observed", would a .update_observation_count (called with 0 or non-zero) method work for you?

@aellwein
Copy link
Contributor Author

Yes, this is exactly what i am looking for.

@chrysn chrysn closed this as completed in 9ae5bdf Mar 31, 2016
@aellwein
Copy link
Contributor Author

Thank you 👍

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

2 participants