Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Beta #27

Merged
merged 4 commits into from
Apr 26, 2021
Merged

Beta #27

merged 4 commits into from
Apr 26, 2021

Conversation

edenhaus
Copy link
Contributor

Created this PR to give you feedback about it


###################################################################

def setScheduleUpdates(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this method completely.
As we have already the different events, then we should schedule only them, when some one is subscribed on the event.
Example components:
We should schedule only self.json.schedule(components_cycle, self.refresh_components), when some is subscribed for the liveSpan events, otherwise we are requesting useless information. This will also decrease the number of requests. What do you think?

My idea was something like:

class EventEmitterWithSchedule(EventEmitter):
    """A event emitter, which starts a scheduler when at least one subscriber is subscribed"""

    def __init__(self, json: EcoVacsJSON, seconds: int, timer_function):
        super().__init__()
        self._json = json
        self._seconds = seconds
        self._timer_function = timer_function

    def subscribe(self, callback) -> EventListener:
        if len(self._subscribers) == 0:
            self._json.schedule(self._seconds, self._timer_function)
        return super().subscribe(callback)

....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@And3rsL what do you think?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a cleaner way to do it :) i need some time to code it

@And3rsL
Copy link
Owner

And3rsL commented Mar 18, 2021

After some day scheduler stop working, need to figure out why

@edenhaus
Copy link
Contributor Author

edenhaus commented Apr 6, 2021

After some day scheduler stop working, need to figure out why

Any findings? Is there something I can help you with?
Until now I didn‘t had any problems but my instance is restarting at least once a week (security updates or config changes)

@And3rsL And3rsL merged commit 93d0c75 into master Apr 26, 2021
@And3rsL And3rsL deleted the beta branch April 26, 2021 13:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants