Skip to content

Commit

Permalink
Revert "Introducing UI update lock. (#186)"
Browse files Browse the repository at this point in the history
This reverts commit e6b1aeb.
  • Loading branch information
RobinTail committed Aug 26, 2023
1 parent e6b1aeb commit ec59a51
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 15 deletions.
5 changes: 0 additions & 5 deletions octoprint_octorelay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ 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 @@ -264,7 +263,6 @@ def reducer(agg, task):
)

def update_ui(self):
self.ui_update_lock = True # issue 186
self._logger.debug("Updating the UI")
settings = self._settings.get([], merged=True) # expensive
upcoming = self.get_upcoming_tasks(filter(
Expand Down Expand Up @@ -292,7 +290,6 @@ def update_ui(self):
"deadline": int(upcoming[index].deadline * 1000) # ms for JS
}
}
self.ui_update_lock = None # issue 186, once model is updated, the lock can be released
self._logger.debug(f"The UI feed: {self.model}")
self._plugin_manager.send_plugin_message(self._identifier, self.model)

Expand All @@ -318,8 +315,6 @@ def get_update_information(self):
# Polling thread
def input_polling(self):
# self._logger.debug("input_polling") # in case your log file is too small
if self.ui_update_lock:
return # issue 186, avoid the update during the another one
for index in RELAY_INDEXES:
active = self.model[index]["active"]
model_state = self.model[index]["relay_state"] # bool since v3.1
Expand Down
10 changes: 0 additions & 10 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,15 +460,6 @@ def test_input_polling(self):
self.plugin_instance.update_ui.assert_called_with()
self.plugin_instance._logger.debug.assert_called_with("relay: r3 has changed its pin state")

def test_input_polling__locked(self):
# Should return immediately when the UI update is locked
self.plugin_instance.ui_update_lock = True
self.plugin_instance.update_ui = Mock()
relayConstructorMock.reset_mock()
self.plugin_instance.input_polling()
self.plugin_instance.update_ui.assert_not_called()
relayConstructorMock.assert_not_called()

def test_update_ui(self):
# Should send message via plugin manager containing actual settings and the relay state
cases = [
Expand Down Expand Up @@ -510,7 +501,6 @@ def test_update_ui(self):
self.plugin_instance._plugin_manager.send_plugin_message.assert_called_with(
"MockedIdentifier", expected_model
)
self.assertIsNone(self.plugin_instance.ui_update_lock)

@patch("os.system")
def test_toggle_relay(self, system_mock):
Expand Down

0 comments on commit ec59a51

Please sign in to comment.