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

Introducing UI update lock. #186

Merged
merged 11 commits into from
Aug 26, 2023
5 changes: 5 additions & 0 deletions octoprint_octorelay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self):
self.polling_timer = None
self.tasks = [] # of Task
self.model = { index: {} for index in RELAY_INDEXES }
self.ui_update_lock = None

def get_settings_version(self):
return SETTINGS_VERSION
Expand Down Expand Up @@ -262,6 +263,9 @@ def reducer(agg, task):
)

def update_ui(self):
if self.ui_update_lock:
return
RobinTail marked this conversation as resolved.
Show resolved Hide resolved
self.ui_update_lock = True
self._logger.debug("Updating the UI")
settings = self._settings.get([], merged=True) # expensive
upcoming = self.get_upcoming_tasks(filter(
Expand Down Expand Up @@ -291,6 +295,7 @@ def update_ui(self):
}
self._logger.debug(f"The UI feed: {self.model}")
self._plugin_manager.send_plugin_message(self._identifier, self.model)
self.ui_update_lock = None

# pylint: disable=useless-return
def process_at_command(self, _comm, _phase, command, parameters, *args, **kwargs):
Expand Down