Skip to content

Attribute observer callbacks are called with heartbeat until disabled - after first called #60

Closed

Description

@eliao

This seems odd to me, particularly because they are labeled "__on_change".

eg: if I do a
vehicle.add_attribute_observer('mode', mode_callback)

mode_callback is called every heartbeat, regardless of mode change.

Activity

  1. changed the title [-]Attribute observer callbacks are called regardless of if the attribute changed. [/-] [+]Attribute observer callbacks are called with heartbeat until disabled - after first called[/+] on May 15, 2015
  2. mrpollo commented on May 28, 2015

    @mrpollo
    Member

    https://github.com/diydrones/dronekit-python/blob/master/droneapi/module/api.py#L440

            elif typ == "HEARTBEAT":
                self.__on_change('mode', 'armed')

    not sure why we did this, @geeksville do you remember this?

  3. geeksville commented on May 28, 2015

    @geeksville
    Collaborator

    Using heartbeat to detect mode changes is a good thing. But yep, it would be much better to also keep a cache of mode and armed inside of the vehicle object and only publish mode and armed if the corresponding boolean changes state.

  4. mrpollo commented on May 28, 2015

    @mrpollo
    Member

    perfect, I think this is what @eliao is calling odd here, I'll submit a PR with some caching, if the mode is still the same we won't publish __on_change('mode') same with armed

  5. mhct commented on Jun 16, 2015

    @mhct

    @mrpollo Perhaps the cache should be done for all other properties as well, since there is no check for evaluating if they have changed or not.

  6. hamishwillee commented on Jun 16, 2015

    @hamishwillee
    Contributor

    @mrpollo @mhct Yes. The bug shows up on all properties not just mode.

  7. hamishwillee commented on Jul 8, 2015

    @hamishwillee
    Contributor

    @mrpollo FYI, it appears that the callback is called more often than the heartbeat - when testing #184 I was getting "lots" of records a second and the heartbeat only comes in once a second. I suspect this means that it is updated whenever a relevant message containing the attribute comes from the vehicle. That would certainly make more sense than updating on heartbeat. Can you confirm? (Note, I assumed this to be correct so that is what #184 states)

    In #184 I explain how you might cache the value and provide notification only when the value changes. I still think this caching should be done by our API.

    When do you think we might get some resource on this?

  8. tcr3dr commented on Jul 16, 2015

    @tcr3dr
    Contributor

    @hamishwillee I'll take over this issue. I think classifying it as a feature (attribute caching) makes it worth a minor release, so it's worth documenting for the 1.3.x branch. I will focus effort on #184 first.

  9. modified the milestones: v1.4.0, on Jul 16, 2015
  10. hamishwillee commented on Jul 16, 2015

    @hamishwillee
    Contributor

    @tcr3dr Just to be precise:

    • The way I think this works is that we publish observed values whenever messages come in with those values. The documentation delivered by Improve Rangefinder attributed documentation #184 assumes this. Can you confirm?
    • It could be that you are saying instead of the above we already cache the incoming values, and what is reported is the last received value, which is reported at some other schedule. If this is the case I'd say it is a bug

    Irrespective of which of the above is happening, arguably we should be publishing the observed value just on change. I think you're saying that we're not going to do that, but stick with the way it is documented in #184.

    Can you confirm please the above points (particularly which of the three options presented here we are aiming for)

  11. tcr3dr commented on Jul 16, 2015

    @tcr3dr
    Contributor

    @hamishwillee Your first point is correct. We do no caching yet, so we are erroneously sending "change" updates when a change may not have occurred.

    So, I can prepare a patch to this, but I do not have enough test cases yet to confirm it will work well. In the meantime, I propose we go ahead, document this behavior (as a bug) via #184, and for the release that fixes this issue we update the documentation accordingly.

    We will still want the documentation to read "Note: Versions before 1.x.x exhibited a bug where..." for the short term, so having it in the docs now is a good start.

  12. hamishwillee commented on Jul 16, 2015

    @hamishwillee
    Contributor

    @tcr3dr Thanks very much. Completely agree.

  13. modified the milestones: v1.5.0, v1.4.0 on Jul 21, 2015
  14. modified the milestones: Minor, v1.5.0 on Aug 12, 2015
  15. modified the milestones: Minor, v2.0.0 on Nov 10, 2015
  16. tcr3dr commented on Nov 11, 2015

    @tcr3dr
    Contributor

    Should be aided by #446. Other attribute callbacks called "too frequently" should be submitted as new bugs so we can make a judgement call on them.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions